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

XF 1.4 Friendly URLs

Discussion in 'Troubleshooting and Problems' started by chrishill, Jan 13, 2015.

  1. chrishill

    chrishill Active Member

    I'm trying to get the friendly URLs working on my website but the pages keep going to 404.

    Here's the config if anyone wouldn't mind helping. Don't I just paste this at the end of my nginx file?

    Code:
    server {
        listen   [::]:80;
        server_name  www.domain.com domain.com;
        root   /usr/share/nginx/html;
        index  index.html index.htm index.php;
        access_log  /usr/share/nginx/html/domain.com.access.log; 
    
        location / {
            try_files            $uri $uri/ /index.php?$uri&$args;
        }
       
        location /data/ {
            allow                127.0.0.1;
            deny                all;
        }
       
        location /internal_data/ {
            allow                127.0.0.1;
            deny                all;
        }
       
        location /library/ {
            allow                127.0.0.1;
            deny                all;
        }
        location ~ \.php$ {
            fastcgi_index            index.php;
            fastcgi_pass            127.0.0.1:9000;
            include                fastcgi.conf;
            fastcgi_intercept_errors    on;
            fastcgi_ignore_client_abort    on;
        }
    
    }
     
  2. Tracy Perry

    Tracy Perry Well-Known Member


    Let me guess... nginx and you are using cut/paste to configure it?

    What OS are you using?
     
  3. chrishill

    chrishill Active Member

    Yes I figured it was sufficient, many guides say variations of this, but apparently it's not accurate. I'm running Ubuntu 14.04.
     
  4. batpool52!

    batpool52! Well-Known Member

    Shouldn't domain.com be your actual domain? Or its just replaced to hide your domain info?
    Also it seems you're missing the root to your forum root.
     
  5. chrishill

    chrishill Active Member

    The forum root is actually just the index. I hid it because the website is not finished and isn't ready to be released.
     
  6. batpool52!

    batpool52! Well-Known Member

    That is not what I meant,
    Code:
        location ~ \.php$ {
            root /var/www/html/domain.com
            fastcgi_index            index.php;
            fastcgi_pass            127.0.0.1:9000;
            include                fastcgi.conf;
            fastcgi_intercept_errors    on;
            fastcgi_ignore_client_abort    on;
        }
    }
    That should be the location where your files are located, like /var/www/html/domain.com/public/ If you're comfortable in giving me access I can fix it for you.
     
  7. chrishill

    chrishill Active Member

    But, on nginx the files are not located there, right? That sounds like Apache to me.
     
  8. batpool52!

    batpool52! Well-Known Member

    It was an example.
     
  9. chrishill

    chrishill Active Member

    It's like this:
    Screen Shot 2015-01-13 at 7.26.42 PM.png
     
  10. batpool52!

    batpool52! Well-Known Member

    So your config should be:
    Code:
    server {
        listen       80;
        server_name  www.domain.com;
    
        charset utf-8;
        access_log  /usr/share/nginx/html/domain.com.access.log;
    
        location / {
            root           /usr/share/nginx/html/;
            index index.php;
            try_files $uri $uri/ /index.php?$uri&$args;
        }
      
        location /internal_data/
        {
            root           /usr/share/nginx/html/;
            internal;
            allow 127.0.0.1;
            deny all;
        }
    
        location /library/
        {
            root           /usr/share/nginx/html/;
            internal;
            allow 127.0.0.1;
            deny all;
        }
    
        location ~ \.php$ {
            root           /usr/share/nginx/html/;
            try_files $uri =404;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    
        location ~ /\.ht {
            deny  all;
        }
    }
    Why haven't you created vhost yet? if its for a live site then do so.
     
  11. chrishill

    chrishill Active Member

    Hmm @batpool52! it's still not working; I'm getting the 404s. Maybe there is some module I need to install.
     
  12. batpool52!

    batpool52! Well-Known Member

    Have you restarted the nginx after making changes? and read what said in below...
     
  13. chrishill

    chrishill Active Member

    Yes I did restart it. I haven't since I do not need more than one website hosted on this server.
     
  14. Tracy Perry

    Tracy Perry Well-Known Member

    Is there a particular reason you went with Ubuntu?
     
  15. chrishill

    chrishill Active Member

    Not really – I have heard good things about it so I thought it would be a good platform. I have used it for other websites too.
     
  16. Tracy Perry

    Tracy Perry Well-Known Member

    Easiest setup for nginx is a centOS/CentMin Mod setup. Works really well and easy to deal with.
     
  17. chrishill

    chrishill Active Member

    Yeah I should have done that @Tracy Perry but I even tried the default setup and I still can't get it working. If my install is in the web root, shouldn't this work?

    Code:
    location / {
        try_files $uri $uri/ /index.php?$uri&$args;
        index index.php index.html;
    }
    
    location /internal_data/ {
        internal;
    }
    location /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;
    }
     
  18. Tracy Perry

    Tracy Perry Well-Known Member

    Code:
        location / {
    ## Deny certain User-Agents (case insensitive)
         ## The ~* makes it case insensitive as opposed to just a ~
         if ($http_user_agent ~* (AHrefs|Baidu|Morfeus|ZmEu|Baiduspider|Jullo|Yandex|Sogou|Baidu) ) {
            return 444;
         }
       
                try_files $uri $uri/ /index.php?$uri&$args;
                index index.php index.html index.htm;
    
    location ~ \.php$ {
       try_files $uri =404;
       fastcgi_split_path_info ^(.+\.php)(/.+)$;
       include fastcgi_params;
       fastcgi_index index.php;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            }
    
    In a nutshell for my base... but you have to have the fastcgi_params also configured.
     
  19. chrishill

    chrishill Active Member

    I used the default one provided by XenForo – any idea why that wouldn't work though? I kept getting a [failed] to restart when I pasted it in the bottom of the config, where I assume it should be pasted ...
     
  20. batpool52!

    batpool52! Well-Known Member

    What is the complete error?
     

Share This Page