Page 1 of 2 1 2 LastLast
Results 1 to 15 of 21

rewrite rules on nginx in sub folder

This is a discussion on rewrite rules on nginx in sub folder within the General Discussion forums, part of the vBulletin SEO Discussion category; I have my blog (wordpress) set up in the /var/www folder with it's own NGINX Virtual Host writes but I ...

  1. #1
    Junior Member
    Real Name
    Bradley
    Join Date
    Apr 2010
    Posts
    18
    Liked
    0 times

    rewrite rules on nginx in sub folder

    I have my blog (wordpress) set up in the /var/www folder with it's own NGINX Virtual Host writes but I need to get the writes set up for the forum in /var/www/forums. What do I need to add exactly the the sheet.

    Code:
    server {
        listen   80;
        server_name  localhost;
        access_log  /var/log/nginx/localhost.access.log;
    
    ## Default location
        location / {
            root   /var/www;
            index  index.php;
        }
    
    ## Images and static content is treated different
        location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
          access_log        off;
          expires           30d;
          root /var/www;
        }
    
    ## Parse all .php file in the /var/www directory
        location ~ .php$ {
            fastcgi_split_path_info ^(.+\.php)(.*)$;
            fastcgi_pass   backend;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /var/www$fastcgi_script_name;
            include fastcgi_params;
            fastcgi_param  QUERY_STRING     $query_string;
            fastcgi_param  REQUEST_METHOD   $request_method;
            fastcgi_param  CONTENT_TYPE     $content_type;
            fastcgi_param  CONTENT_LENGTH   $content_length;
            fastcgi_intercept_errors        on;
            fastcgi_ignore_client_abort     off;
            fastcgi_connect_timeout 60;
            fastcgi_send_timeout 180;
            fastcgi_read_timeout 180;
            fastcgi_buffer_size 128k;
            fastcgi_buffers 4 256k;
            fastcgi_busy_buffers_size 256k;
            fastcgi_temp_file_write_size 256k;
        }
    
    ## Disable viewing .htaccess & .htpassword
        location ~ /\.ht {
            deny  all;
        }
    }
    upstream backend {
            server 127.0.0.1:9000;
    }

  2. #2
    vBSEO Staff Brian Cummiskey's Avatar
    Real Name
    Brian Cummiskey
    Join Date
    Jul 2009
    Location
    btwn NYC and Boston
    Posts
    12,789
    Liked
    657 times
    Blog Entries
    2
    Hello,

    You can't have your blog in the same directory as your forum.

  3. #3
    Junior Member
    Real Name
    Bradley
    Join Date
    Apr 2010
    Posts
    18
    Liked
    0 times
    Oh wait, I meant blog at

    /var/www


    Forum at

    /var/www/forums

    Was a bit tired last night

  4. #4
    vBSEO.com Webmaster Mert Gökçeimam's Avatar
    Real Name
    Lizard King
    Join Date
    Oct 2005
    Location
    Istanbul, Turkey, Turkey
    Posts
    23,100
    Liked
    622 times
    Blog Entries
    4
    Hello Bradley ,

    You need to define another location for forums directory with the supplied nginx rules within vBSEO.
    Mert Gökçeimam / Crawlability Inc.

    vBSEO 3.6.0 Alpha Önizlemesi - Including Like Tree
    Unveiling the NEW vBSEO Sitemap Generator 3.0 - available NOW for vBSEO Customers!


    Twitter:@Depkac
    Personal Blog : Mert Gökçeimam

  5. #5
    Junior Member
    Real Name
    Bradley
    Join Date
    Apr 2010
    Posts
    18
    Liked
    0 times
    Do these rules still apply? howto for nginx

    Coincidentally the set up is the same.

    Code:
    location /forums/ {  rewrite ^/forums/((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ /forums/vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 last;  if ($request_filename ~ "\.php$" ) { rewrite ^(.*)$ /forums/vbseo.php last; }  if (!-e $request_filename) { rewrite ^/forums/(.*)$ /forums/vbseo.php last; }  }

  6. #6
    vBSEO.com Webmaster Mert Gökçeimam's Avatar
    Real Name
    Lizard King
    Join Date
    Oct 2005
    Location
    Istanbul, Turkey, Turkey
    Posts
    23,100
    Liked
    622 times
    Blog Entries
    4
    Please use the nginx rules that comes with vBSEO package . You can find the rules inside htaccess folder.
    Mert Gökçeimam / Crawlability Inc.

    vBSEO 3.6.0 Alpha Önizlemesi - Including Like Tree
    Unveiling the NEW vBSEO Sitemap Generator 3.0 - available NOW for vBSEO Customers!


    Twitter:@Depkac
    Personal Blog : Mert Gökçeimam

  7. #7
    Junior Member
    Real Name
    Bradley
    Join Date
    Apr 2010
    Posts
    18
    Liked
    0 times
    Ok im confused honestly. I currently have the 'default' V file including the directives in the first post in my /etc/nginx/sites-enabled folder on the server.

    Where am I inserting the vbseo nginx directives? In the same default file or in a new file? and if it's in the default file, can you show me in between where?

  8. #8
    vBSEO.com Webmaster Mert Gökçeimam's Avatar
    Real Name
    Lizard King
    Join Date
    Oct 2005
    Location
    Istanbul, Turkey, Turkey
    Posts
    23,100
    Liked
    622 times
    Blog Entries
    4
    You can define them in same file

    Code:
    server {
        listen   80;
        server_name  localhost;
        access_log  /var/log/nginx/localhost.access.log;
    
    ## Default location
        location / {
            root   /var/www;
            index  index.php;
        }
    
    ## Images and static content is treated different
        location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
          access_log        off;
          expires           30d;
          root /var/www;
        }
    
    ## Parse all .php file in the /var/www directory
        location ~ .php$ {
            fastcgi_split_path_info ^(.+\.php)(.*)$;
            fastcgi_pass   backend;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /var/www$fastcgi_script_name;
            include fastcgi_params;
            fastcgi_param  QUERY_STRING     $query_string;
            fastcgi_param  REQUEST_METHOD   $request_method;
            fastcgi_param  CONTENT_TYPE     $content_type;
            fastcgi_param  CONTENT_LENGTH   $content_length;
            fastcgi_intercept_errors        on;
            fastcgi_ignore_client_abort     off;
            fastcgi_connect_timeout 60;
            fastcgi_send_timeout 180;
            fastcgi_read_timeout 180;
            fastcgi_buffer_size 128k;
            fastcgi_buffers 4 256k;
            fastcgi_busy_buffers_size 256k;
            fastcgi_temp_file_write_size 256k;
        }
    location /forums/ {
    
    rewrite ^/forums/((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ /forums/vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 last;
    
    if (!-e $request_filename) {
    rewrite ^/forums/(.*)$ /forums/vbseo.php last;
    }
    
    }
    
    if ($request_filename ~ "\.php$" ) {
    rewrite ^/forums/(.*)$ /forums/vbseo.php last;
    }
    
    ## Disable viewing .htaccess & .htpassword
        location ~ /\.ht {
            deny  all;
        }
    }
    upstream backend {
            server 127.0.0.1:9000;
    }
    I personally choose to keep all conf files for different folders and domains on a seperate conf file and include them with the following directive
    Code:
        include /etc/nginx/sites/*.conf;
    On my main conf file , i don't even have single server line defined.
    Mert Gökçeimam / Crawlability Inc.

    vBSEO 3.6.0 Alpha Önizlemesi - Including Like Tree
    Unveiling the NEW vBSEO Sitemap Generator 3.0 - available NOW for vBSEO Customers!


    Twitter:@Depkac
    Personal Blog : Mert Gökçeimam

  9. #9
    Junior Member
    Real Name
    Bradley
    Join Date
    Apr 2010
    Posts
    18
    Liked
    0 times
    Ok I see now what I also forgot to mention. I copied the wrong set up. Also I didnt bother to separate the files per host since it was only one site. However if you have a better recommendation, please show me. In the middle, there are directives for the blog which I think may cause conflicts for the forum.

    This is the corrected directive I use (before vbseo)

    Code:
    server {
        listen   80;
        server_name  motorthusiast.com www.motorthusiast.com;
        access_log  /var/log/nginx/localhost.access.log;
    
    ## Force WWW
        if ($host ~* ^motorthusiast\.com) {
            rewrite ^(.*)$ http://www.motorthusiast.com$1 permanent;
        }
    
    
    ## Default location
        location / {
            root   /var/www;
            index  index.php;
    
    
    ## this sends all non-existing file or directory requests to index.php
            if (!-e $request_filename) {
                rewrite ^(.+)$ /index.php?q=$1 last;
            }
    
    
        }
    
    ## Images and static content is treated different
        location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
          access_log        off;
          expires           30d;
          root /var/www;
        }
    
    ## Parse all .php file in the /var/www directory
        location ~ .php$ {
            fastcgi_split_path_info ^(.+\.php)(.*)$;
            fastcgi_pass   backend;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /var/www$fastcgi_script_name;
            include fastcgi_params;
            fastcgi_param  QUERY_STRING     $query_string;
            fastcgi_param  REQUEST_METHOD   $request_method;
            fastcgi_param  CONTENT_TYPE     $content_type;
            fastcgi_param  CONTENT_LENGTH   $content_length;
            fastcgi_intercept_errors        on;
            fastcgi_ignore_client_abort     off;
            fastcgi_connect_timeout 60;
            fastcgi_send_timeout 180;
            fastcgi_read_timeout 180;
            fastcgi_buffer_size 128k;
            fastcgi_buffers 4 256k;
            fastcgi_busy_buffers_size 256k;
            fastcgi_temp_file_write_size 256k;
        }
    
    
    ## Disable viewing .htaccess & .htpassword
        location ~ /\.ht {
            deny  all;
        }
    }
    upstream backend {
            server 127.0.0.1:9000;
    }

  10. #10
    vBSEO.com Webmaster Mert Gökçeimam's Avatar
    Real Name
    Lizard King
    Join Date
    Oct 2005
    Location
    Istanbul, Turkey, Turkey
    Posts
    23,100
    Liked
    622 times
    Blog Entries
    4
    We are sorry both Nginx customization is beyond our support. As i showed you should use the supplied nginx rules within vBSEO package.
    Mert Gökçeimam / Crawlability Inc.

    vBSEO 3.6.0 Alpha Önizlemesi - Including Like Tree
    Unveiling the NEW vBSEO Sitemap Generator 3.0 - available NOW for vBSEO Customers!


    Twitter:@Depkac
    Personal Blog : Mert Gökçeimam

  11. #11
    Junior Member
    Real Name
    Bradley
    Join Date
    Apr 2010
    Posts
    18
    Liked
    0 times
    Wow that sucks. I tried your example but get "Page Not Found" everytime I try to view forums. Could this line be a conflicting issue?

    if (!-e $request_filename) { rewrite ^(.+)$ /index.php?q=$1 last; }

    Edit - I also have a suspicion something may be of conflict. For example when I visit a thread via the old URL format, it then give me the URL to the newly permalink friendly format but the subfolder 'forums' is missing.

    http://www.motorthusiast.com/forums/showthread.php?t=15

    goes to

    http://www.motorthusiast.com/aston-m...martin-db9-15/

    rather than


    http://www.motorthusiast.com/forums/...martin-db9-15/

  12. #12
    vBSEO.com Webmaster Mert Gökçeimam's Avatar
    Real Name
    Lizard King
    Join Date
    Oct 2005
    Location
    Istanbul, Turkey, Turkey
    Posts
    23,100
    Liked
    622 times
    Blog Entries
    4
    Make sure your php files are correctly processed within forums folder.
    Last edited by Mert Gökçeimam; 09-16-2010 at 11:31 PM.
    Mert Gökçeimam / Crawlability Inc.

    vBSEO 3.6.0 Alpha Önizlemesi - Including Like Tree
    Unveiling the NEW vBSEO Sitemap Generator 3.0 - available NOW for vBSEO Customers!


    Twitter:@Depkac
    Personal Blog : Mert Gökçeimam

  13. #13
    Junior Member
    Real Name
    Bradley
    Join Date
    Apr 2010
    Posts
    18
    Liked
    0 times
    My final conclusion is that

    Code:
    if (!-e $request_filename) {
                rewrite ^(.+)$ /index.php?q=$1 last;
            }
    is causing the forum to use the main domain and delete the /forum part. However that bit is also necessary for the functioning of the main blog itself, so I need some kind of combination so when someone is on the home page, is uses that but in the forum, it uses the forum directives instead.

  14. #14
    vBSEO.com Webmaster Mert Gökçeimam's Avatar
    Real Name
    Lizard King
    Join Date
    Oct 2005
    Location
    Istanbul, Turkey, Turkey
    Posts
    23,100
    Liked
    622 times
    Blog Entries
    4
    If you are using forums folder , then you need to update the rewrite rules and define forums folder. Please supply your full nginx.conf file now so we can see how you edited it.
    Mert Gökçeimam / Crawlability Inc.

    vBSEO 3.6.0 Alpha Önizlemesi - Including Like Tree
    Unveiling the NEW vBSEO Sitemap Generator 3.0 - available NOW for vBSEO Customers!


    Twitter:@Depkac
    Personal Blog : Mert Gökçeimam

  15. #15
    Junior Member
    Real Name
    Bradley
    Join Date
    Apr 2010
    Posts
    18
    Liked
    0 times
    nginx.zip

    Right, that's the main configuration file and the virtual host file.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Nginx rules don't redirect old showthread.php URLs
    By Inettive in forum General Discussion
    Replies: 4
    Last Post: 01-10-2010, 03:19 AM
  2. Rewrite from Apache to nginx
    By Hiiragi in forum URL Rewrite Settings
    Replies: 0
    Last Post: 07-13-2009, 07:04 PM
  3. Rewrite from apache to nginx
    By nfn in forum Custom Rewrite Rules
    Replies: 6
    Last Post: 01-27-2009, 08:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •