vBulletin Rewrite Rules on nginx

I'm currently using the following nginx rewrite rules for my CMS, Blog, and Forums, which I've found posted in these forums: (Currently, while we're getting this set up, we're working on linode. davidkarol. com, and plan to move over this Friday)

rewrite ^/threads/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) /showthread.php?t=$1&page=$2;
rewrite ^/members/([0-9]+) /member.php?u=$1;
rewrite ^/forums/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) /forumdisplay.php?f=$1&page=$2;$
rewrite ^/blogs/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) /blog.php?u=$1&page=$2;
rewrite ^/entries/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) /entry.php?b=$1&page=$2;
rewrite ^/list/([^/]*/)([0-9]+) /list.php?r=$1$2;
rewrite ^/content/(.*) /content.php?r=$1;

I can't load actual threads, posts, and blogs. After making some changes, I'm able to load the members list, along with the list of threads (each forum.) Here's my config file for the virtual host, and then that for nginx itself (slightly modified):

server {
    listen   80;
    server_name example.com;
    access_log /home/sfn/www/example.net/logs/access.log;
    error_log /home/sfn/www/example.net/logs/error.log;
        root   /home/sfn/www/example.net/public_html/;

    location / {
        index index.php  index.html index.htm;
        rewrite ^/live/threads/([0-9]+)  /showthread.php?t=$1&page=$2;
        rewrite ^/live/members/([0-9]+) /member.php?u=$1;
#       rewrite ^/live/forums/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) /forumdisplay.php?$
        rewrite ^/live/forums/([0-9]+) /forumdisplay.php?f=$1;
        rewrite ^/blogs/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) /blog.php?u=$1&page=$2;
        rewrite ^/entries/([0-9]+)(?:/?$|(?:-[^/]+))(?:/?$|(?:/page([0-9]+)?)) /entry.php?b=$1&page=$
        rewrite ^/list/([^/]*/)([0-9]+) /list.php?r=$1$2;
        rewrite ^/content/(.*) /content.php?r=$1;
   }

   }

    # Pass PHP scripts on to PHP-FPM
    location ~* \.php$ {
        try_files       $uri /index.php;
        fastcgi_index   index.php;
        fastcgi_pass    127.0.0.1:9000;
        include         fastcgi_params;
        fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
        fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
    }
}
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";
        gzip_disable "msie6";

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/x-javascript text/xml applicati$

        ##
        # If HTTPS, then set a variable so it can be passed along.
        ##

        map $scheme $server_https {
                default off;
                https on;
        }

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

In addition, the rules being used on the old Apache server in each directory are below:

Here is the rewriting section I was using on Apache from first the root folder, than the forum and blog stub directories:

Root:

RewriteCond %{REQUEST_FILENAME} -s [OR]RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^.*$ - [NC,L]

# Forum
RewriteRule ^threads/.* showthread.php [QSA]
RewriteRule ^forums/.* forumdisplay.php [QSA]
RewriteRule ^members/.* member.php [QSA]
RewriteRule ^blogs/.* blog.php [QSA]
RewriteRule ^entries/.* entry.php [QSA]

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^.*$ - [NC,L]

# MVC
RewriteCond %{REQUEST_FILENAME} !\.php$
RewriteRule ^(?:(.*?)(?:/|$))(.*|$)$ $1.php?r=$2 [QSA]

Forum (/live)

RewriteCond %{REQUEST_FILENAME} -f [OR]RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^.*$ - [NC,L]

# Forum
RewriteRule ^threads/.* showthread.php [QSA]
RewriteRule ^forums/.* forumdisplay.php [QSA]
RewriteRule ^members/.* member.php [QSA]

Blog (/blog)

RewriteCond %{REQUEST_FILENAME} -s [OR]RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^.*$ - [NC,L]

RewriteRule ^blogs/.* blog.php [QSA]
RewriteRule ^entries/.* entry.php [QSA]

Any ideas?

Thanks,

dk

0 Replies

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct