Results 1 to 7 of 7

Need Advice With Nginx Rewrite Rule

This is a discussion on Need Advice With Nginx Rewrite Rule within the General Discussion forums, part of the vBulletin SEO Discussion category; Hello, Currently i use litespeed but i will migrated to nginx, i have tested it on my localhost here is ...

  1. #1
    Junior Member
    Real Name
    prandah
    Join Date
    Dec 2011
    Location
    Indonesia
    Posts
    18
    Liked
    0 times

    Unhappy Need Advice With Nginx Rewrite Rule

    Hello,
    Currently i use litespeed but i will migrated to nginx,
    i have tested it on my localhost
    here is my sites-enabled

    PHP Code:
    server {
      
    #move the server_name 'www.' to rewrite
      #if you prefer www.domain.com
      
    server_name  www.domain.org;
      
    rewrite ^/(.*) http://domain.org$1 permanent;
    }

    server {
      
    listen 80;
      
    #add 'www.' prefix if you prefer www.domain.com
      
    server_name domain.org;
      
    access_log /home/www/domain.org/logs/access.log;
      
    error_log /home/www/domain.org/logs/error.log;

      
    location / {
        
    root /home/www/domain.org/public_html/;
        
    index index.html index.htm index.php;
        }

      
    location /home/www/domain.org/public_html/ {
        
    rewrite ^/home/www/domain.org/public_html/((urllist|sitemap_).*\.(xml|txt)(\.gz)?)?sitemap=$1 last;

        
    try_files $uri $uri/ /home/www/domain.org/public_html/vbseo.php?$args;
        }

      
    location ~ /home/www/domain.org/public_html/(.*\.php)$ {
        
    rewrite ^/home/www/domain.org/public_html/(.*)$ /home/www/domain.org/public_html/
        }

      
    location /home/www/domain.org/public_html/vbseo/(includes|resources/html|resources/x
        allow      127.0.0.1
    ;
        
    deny      all;
        }

      
    location ~ \.php$ {
        include /
    etc/nginx/fastcgi_params;
        
    fastcgi_pass 127.0.0.1:9000;
        
    fastcgi_index index.php;
        
    fastcgi_param SCRIPT_FILENAME /home/www/domain.org/public_html$fastcgi_script_name
      
    }


    but still 404 not found :(

    and here my nginx.conf

    PHP Code:
    [root@server1 nginx]# cat nginx.conf
    #######################################################################
    #
    # This is the main Nginx configuration file.
    #
    # More information about the configuration options is available on
    #   * the English wiki - http://wiki.codemongers.com/Main
    #   * the Russian documentation - http://sysoev.ru/nginx/
    #
    #######################################################################

    #----------------------------------------------------------------------
    # Main Module - directives that cover basic functionality
    #
    #   http://wiki.codemongers.com/NginxMainModule
    #
    #----------------------------------------------------------------------

    user              www www;
    worker_processes  4;

    error_log         /var/log/nginx/error.log;
    #error_log        /var/log/nginx/error.log  notice;
    #error_log        /var/log/nginx/error.log  info;

    pid               /var/run/nginx.pid;


    #----------------------------------------------------------------------
    # Events Module
    #
    #   http://wiki.codemongers.com/NginxEventsModule
    #
    #----------------------------------------------------------------------

    events {
        
    worker_connections  1024;
    }


    #----------------------------------------------------------------------
    # HTTP Core Module
    #
    #   http://wiki.codemongers.com/NginxHttpCoreModule
    #
    #----------------------------------------------------------------------

    http {
        include       /
    etc/nginx/mime.types;
        
    default_type  application/octet-stream;
            
    client_max_body_size 10M;
            
    client_body_buffer_size 128k;

        
    log_format  main  ' -  []  '
                          '""  "" '
                          '"" ""'
    ;

        
    access_log  /var/log/nginx/access.log  main;

        
    sendfile        on;
        
    tcp_nopush     on;

        
    keepalive_timeout  65;
            
    tcp_nodelay on;

        
    gzip  on;

        
    # Load config files from the /etc/nginx/conf.d directory
        
    include /etc/nginx/conf.d/*.conf;

        #
        # The default server
        #

        server {
                    listen      443;
                    server_name 199.36.123.126;
                    ssl on;
            ssl_certificate      /etc/nginx/sslconf/server.crt;
            ssl_certificate_key  /etc/nginx/sslconf/server.key;
                    location /myadminphp {
                            root /usr/html;
                            index index.php;
                    }
            location ~ \.php$ {
                include /etc/nginx/fastcgi_params;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME /usr/html$fastcgi_script_name;
                            fastcgi_param HTTPS on;
            }
            }

        server {
            listen       80;
            server_name  199.36.123.126;
            #charset koi8-r;
            #access_log  logs/host.access.log  main;
            location / {
                root   /usr/html;
                index  index.html index.htm index.php;
            }
                    location = /myadminphp/ {
                            rewrite ^ https://199.36.123.126$uri redirect;
                    }

            error_page  404              /404.html;
            location = /404.html {
                root   /usr/html;
            }

            # redirect server error pages to the static page /50x.html
            #
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   /usr/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$ {
                      include /etc/nginx/fastcgi_params;
                      fastcgi_pass 127.0.0.1:9000;
                      fastcgi_index index.php;
                      fastcgi_param SCRIPT_FILENAME /usr/html$fastcgi_script_name;
                    }
            #}

            # deny access to .htaccess files, if Apache's document root
            # concurs with nginx's one
            #
            location ~ /\.ht {
                deny  all;
            }
        }
            # Load virtual host configuration files.
          include /etc/nginx/sites-enabled/*;
    }

    [root@server1 nginx]# 

  2. #2
    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 ,

    Your nginx configuration is wrong. Your sites-enabled file should have following content

    Code:
    server {  #move the server_name 'www.' to rewrite
      #if you prefer www.domain.com
      server_name  www.domain.org;
      rewrite ^/(.*) http://domain.org$1 permanent;
    }
    
    
    server {
      listen 80;
      #add 'www.' prefix if you prefer www.domain.com
      server_name domain.org;
      access_log /home/www/domain.org/logs/access.log;
      error_log /home/www/domain.org/logs/error.log;
    
    
      location / {
        root /home/www/domain.org/public_html/;
        index index.html index.htm index.php;
        }
      location / {
        rewrite ^/((urllist|sitemap_).*\.(xml|txt)(\.gz)?)?sitemap=$1 last;
    
    
        try_files $uri $uri/ /vbseo.php?$args;
        }
    
    
      location ~ /(.*\.php)$ {
        rewrite ^/(.*)$ /
        }
    
    
      location /vbseo/(includes|resources/html|resources/x
        allow      127.0.0.1;
        deny      all;
        }
      location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /home/www/domain.org/public_html$fastcgi_script_name
      }
    
    
    }
    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

  3. #3
    Junior Member
    Real Name
    prandah
    Join Date
    Dec 2011
    Location
    Indonesia
    Posts
    18
    Liked
    0 times
    PHP Code:
    [root@server1 sites-enabled]# cat domain.org
    server {
      
    #move the server_name 'www.' to rewrite
      #if you prefer www.domain.com
      
    server_name  www.domain.org;
      
    rewrite ^/(.*) http://ditusuk.org$1 permanent;
    }

    server {
      
    listen 80;
      
    #add 'www.' prefix if you prefer www.domain.com
      
    server_name domain.org;
      
    access_log /home/www/domain.org/logs/access.log;
      
    error_log /home/www/domain.org/logs/error.log;

      
    location / {
        
    root /home/www/domain.org/public_html/;
        
    index index.html index.htm index.php;
        }
      
    location / {
        
    rewrite ^/((urllist|sitemap_).*\.(xml|txt)(\.gz)?)?sitemap=$1 last;

        
    try_files $uri $uri/ /vbseo.php?$args;
        }
      
    location ~ /(.*\.php)$ {
        
    rewrite ^/(.*)$ /
        }
      
    location /vbseo/(includes|resources/html|resources/x
        allow      127.0.0.1
    ;
        
    deny      all;
        }

      
    location ~ \.php$ {
        include /
    etc/nginx/fastcgi_params;
        
    fastcgi_pass 127.0.0.1:9000;
        
    fastcgi_index index.php;
        
    fastcgi_param SCRIPT_FILENAME /home/www/domain.org/public_html$fastcgi_script_name;
      }

    }


    [
    root@server1 sites-enabled]
    [root@server1 sites-enabled]# service nginx restart
    nginx: [emerg] unexpected "}" in /etc/nginx/sites-enabled/domain.org:26
    nginx: configuration file /etc/nginx/nginx.conf test failed
    [root@server1 sites-enabled]#

  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 ,

    I checked your account and i don't see a test license defined to your account. You should note that vBSEO will only function within registered domain name. Additionally the only difference within i applied to your nginx rules is correcting path in your location. If you are receiving an error , you need to bypass the error as it is not caused by any defined vBSEO rule at all.
    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
    prandah
    Join Date
    Dec 2011
    Location
    Indonesia
    Posts
    18
    Liked
    0 times
    lo,
    i'm sorry before i use to my second domain
    to test it rewrite on nginx
    to day i'm use nginx as webserver
    my domain ditusuk.com

    [root@poseidon sites-enabled]# /etc/init.d/nginx restart
    nginx: [emerg] unexpected "}" in /etc/nginx/sites-enabled/ditusuk.com:27
    nginx: configuration file /etc/nginx/nginx.conf test failed
    [root@poseidon sites-enabled]#

    and here for my sites-enabled

    PHP Code:
    [root@poseidon sites-enabled]# cat ditusuk.com
    server {
      
    #move the server_name 'www.' to rewrite
      #if you prefer www.domain.com
      
    server_name  ditusuk.com;
      
    rewrite ^/(.*) http://www.ditusuk.com$1 permanent;
    }

    server {
      
    listen 80;
      
    #add 'www.' prefix if you prefer www.domain.com
      
    server_name www.ditusuk.com;
      
    access_log /home/www/ditusuk.com/logs/access.log;
      
    error_log /home/www/ditusuk.com/logs/error.log;

      
    location / {
        
    root /home/www/ditusuk.com/public_html/;
        
    index index.html index.htm index.php;
      }

      
    location / {
        
    rewrite ^/((urllist|sitemap_).*\.(xml|txt)(\.gz)?)?sitemap=$1 last;

        
    try_files $uri $uri/ /vbseo.php?$args;
        }
      
    location ~ /(.*\.php)$ {
        
    rewrite ^/(.*)$ /
        }
      
    location /vbseo/(includes|resources/html|resources/x
        allow      127.0.0.1
    ;
        
    deny      all;
        }

      
    location ~ \.php$ {
        include /
    etc/nginx/fastcgi_params;
        
    fastcgi_pass 127.0.0.1:9000;
        
    fastcgi_index index.php;
        
    fastcgi_param SCRIPT_FILENAME /home/www/ditusuk.com/public_html$fastcgi_script_name;
      }
    }
    [
    root@poseidon sites-enabled]

  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
    In that file there is no error , you need to check your other conf files and identify the error .
    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
    prandah
    Join Date
    Dec 2011
    Location
    Indonesia
    Posts
    18
    Liked
    0 times
    ere is my nginx.conf

    [root@poseidon nginx]# cat nginx.conf
    ################################################## #####################
    #
    # This is the main Nginx configuration file.
    #
    # More information about the configuration options is available on
    # * the English wiki - Main
    # * the Russian documentation - nginx
    #
    ################################################## #####################

    #----------------------------------------------------------------------
    # Main Module - directives that cover basic functionality
    #
    # CoreModule
    #
    #----------------------------------------------------------------------

    user www www;
    worker_processes 8;

    error_log /var/log/nginx/error.log;
    #error_log /var/log/nginx/error.log notice;
    #error_log /var/log/nginx/error.log info;

    pid /var/run/nginx.pid;


    #----------------------------------------------------------------------
    # Events Module
    #
    # http://wiki.codemongers.com/NginxEventsModule
    #
    #----------------------------------------------------------------------

    events {
    worker_connections 1024;
    }


    #----------------------------------------------------------------------
    # HTTP Core Module
    #
    # HttpCoreModule
    #
    #----------------------------------------------------------------------

    http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    client_max_body_size 8M;
    client_body_buffer_size 128k;

    log_format main ' - [] '
    '"" "" '
    '"" ""';

    access_log /var/log/nginx/access.log main;

    sendfile on;
    tcp_nopush on;

    keepalive_timeout 65;
    tcp_nodelay on;

    gzip on;

    # Load config files from the /etc/nginx/conf.d directory
    include /etc/nginx/conf.d/*.conf;

    #
    # The default server
    #

    server {
    listen 443;
    server_name 74.117.59.214;
    ssl on;
    ssl_certificate /etc/nginx/sslconf/server.crt;
    ssl_certificate_key /etc/nginx/sslconf/server.key;
    location /myadminphp {
    root /usr/html;
    index index.php;
    }
    location ~ \.php$ {
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /usr/html$fastcgi_script_name;
    fastcgi_param HTTPS on;
    }
    }

    server {
    listen 80;
    server_name 74.117.59.214;
    #charset koi8-r;
    #access_log logs/host.access.log main;
    location / {
    root /usr/html;
    index index.html index.htm index.php;
    }
    location = /myadminphp/ {
    rewrite ^ https://74.117.59.214$uri redirect;
    }

    error_page 404 /404.html;
    location = /404.html {
    root /usr/html;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root /usr/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$ {
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /usr/html$fastcgi_script_name;
    }
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
    deny all;
    }
    }
    # Load virtual host configuration files.
    include /etc/nginx/sites-enabled/*;
    }

    [root@poseidon nginx]#

Similar Threads

  1. rewrite for nginx ver 3.6.0
    By shell in forum URL Rewrite Settings
    Replies: 4
    Last Post: 01-09-2011, 06:59 PM
  2. Which rewrite rule to use
    By slinky in forum URL Rewrite Settings
    Replies: 11
    Last Post: 11-09-2010, 01:04 PM
  3. Converting .htaccess rewrite rule to vbseo rewrite
    By tscargo in forum Custom Rewrite Rules
    Replies: 1
    Last Post: 04-20-2009, 02:34 PM
  4. Rewrite Rule
    By Floezen in forum Troubleshooting
    Replies: 2
    Last Post: 07-23-2008, 05:59 PM

Posting Permissions

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