1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.2 nginx friendly url rewrite

Discussion in 'Troubleshooting and Problems' started by optrex, Jul 26, 2013.

  1. optrex

    optrex Active Member

    I'm new to nginx and I'm struggling with the friendly url rewrite.
    I've added the relevant xenforo rewrite riles in between the ####### markers, but I still get a 404

    Can anyone help please?

    Code:
     root  /var/www/forum/htdocs;
            index  index.html index.htm index.php;
        }
    
        error_page  404              /404.html;
        location = /404.html {
            root  /usr/share/nginx/html;
        }
    
    ############
    location /var/www/forum/htdocs/ {
            try_files $uri $uri/ /xf/index.php?$uri&$args;
            index index.php index.html;
    }
    location /var/www/forum/htdocs/internal_data/ {
            internal;
    }
    location /var/www/forum/htdocs/library/ {
          internal;
    }
     location ~ \.php$ {
           try_files $uri =404;
           fastcgi_pass    127.0.0.1:9000;
           fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
           include        fastcgi_params;
     }
    #############
        # redirect server error pages to the static page /50x.html
        #
        error_page  500 502 503 504  /50x.html;
        location = /50x.html {
            root  /usr/share/nginx/html;
        }
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass  http://127.0.0.1;
        #}
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root          /var/www/forum/htdocs;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index  index.php;
            try_files $uri =403;
            fastcgi_param  SCRIPT_FILENAME $request_filename;
            include        fastcgi_params;
    }
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
    
     
  2. JulianD

    JulianD Well-Known Member

    You need to rename /xf to whatever path your forum is located.
     
    optrex likes this.
  3. optrex

    optrex Active Member

    I thought I had in the example given. Have I missed something?
     
  4. Jeremy

    Jeremy XenForo Moderator Staff Member

    Code:
    root  /var/www/forum/htdocs;
            index  index.html index.htm index.php;
        }
    
        error_page  404              /404.html;
        location = /404.html {
            root  /usr/share/nginx/html;
        }
    
    ############
    location /var/www/forum/htdocs/ {
            try_files $uri $uri/ /xf/index.php?$uri&$args;
            index index.php index.html;
    }
    location /var/www/forum/htdocs/internal_data/ {
            internal;
    }
    location /var/www/forum/htdocs/library/ {
          internal;
    }
    location ~ \.php$ {
           try_files $uri =404;
           fastcgi_pass    127.0.0.1:9000;
           fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
           include        fastcgi_params;
    }
    #############
        # redirect server error pages to the static page /50x.html
        #
        error_page  500 502 503 504  /50x.html;
        location = /50x.html {
            root  /usr/share/nginx/html;
        }
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass  http://127.0.0.1;
        #}
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root          /var/www/forum/htdocs;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index  index.php;
            try_files $uri =403;
            fastcgi_param  SCRIPT_FILENAME $request_filename;
            include        fastcgi_params;
    }
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
    You missed a spot that I've highlighted in red above.
     
    optrex likes this.
  5. optrex

    optrex Active Member

    Thank you both. I've made the change to the /xf/ that I missed, but I am still getting 404 errors event after reloading the service.
     
  6. optrex

    optrex Active Member

    ah, I've commented out one of the locations and that has enabled it to work, thanks for the assistance.
     

Share This Page