Learn about Centmin Mod LEMP Stack today
Register Now

Xenforo friendly url not working (xenforo)

Discussion in 'Forum software usage' started by maria, Mar 1, 2015.

  1. maria

    maria New Member

    10
    2
    3
    Mar 1, 2015
    Ratings:
    +2
    Local Time:
    5:14 AM
    5.5
    Hello,

    When I try to add the code to make friendly url work for xenforo I am unable to restart nginx.

    Here is the code added:

    Code:
    nginx: [emerg] "location" directive is not allowed here in /usr/local/nginx/conf/staticfiles.conf:1
    What can I do to fix this? Thank you.
     
  2. eva2000

    eva2000 Administrator Staff Member

    41,672
    9,380
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,413
    Local Time:
    7:14 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
  3. maria

    maria New Member

    10
    2
    3
    Mar 1, 2015
    Ratings:
    +2
    Local Time:
    5:14 AM
    5.5
    ok i think i fixed it now, I diddn't copy your edits properly :)

    Edit: I can restart fine now but I still get 404 when using friendly url, here is my config

    Code:
    # redirect from non-www to www
    # uncomment, save file and restart Nginx to enable
    #server {
    #            listen   80;
    #            server_name mydomain.com;
    #            return 301 $scheme://www.mydomain.com$request_uri;
    #       }
    
    server {
      server_name mydomain.com www.mydomain.com;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/mydomain.com/log/access.log combined buffer=32k;
      error_log /home/nginx/domains/mydomain.com/log/error.log;
    
      root /home/nginx/domains/mydomain.com/public;
    
            location /forum/ {
                index index.php index.html index.htm;
                try_files $uri $uri/ /index.php?$uri&$args;    
            }
    
            location /forum/internal_data/ {
            internal;
            allow 127.0.0.1;
            deny all;
            }
    
            location /forum/library/ {
            internal;
            allow 127.0.0.1;
            deny all;
            }
    
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/php.conf;
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
    }
    
    # block common exploits, sql injections etc
    #include /usr/local/nginx/conf/block.conf;
    
      # Enables directory listings when index file not found
      #autoindex  on;
    
      # Shows file listing times as local time
      #autoindex_localtime on;
    
      # Enable for vBulletin usage WITHOUT vbSEO installed
      #try_files        $uri $uri/ /index.php;
    
     
    Last edited: Mar 1, 2015
  4. eva2000

    eva2000 Administrator Staff Member

    41,672
    9,380
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,413
    Local Time:
    7:14 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    for sub directories as per outline at Nginx Rewrites for Xenforo Friendly Urls need to add /forum/ in front of try_files index.php
    Code:
            location /forum/ {
                index index.php index.html index.htm;
                try_files $uri $uri/ /forum/index.php?$uri&$args;  
            }
     
    • Useful Useful x 1
  5. maria

    maria New Member

    10
    2
    3
    Mar 1, 2015
    Ratings:
    +2
    Local Time:
    5:14 AM
    5.5
    yes yes yes yes!!!! it works thanks so much
     
    • Like Like x 1