server { # Insert your general directives (listen, server_name, root, gzip...) here. # Treat / as /index.php. (But don't redirect to it.) location = / { rewrite .* /index.php last; } # Handle PHP scripts. location ~ \.php$ { # Insert your configurations for processing PHP files here. (At Agora, we # use FastCGI, which means using the fastcgi_pass directive.) } location / { # Handle directories. (This is a bit of a hack, but it allows NGINX to play # nicely with a PHP index file. You can always do something a bit smarter # here if you prefer, for example: "if (-f $request_filename/index.php)") if (-d $request_filename) { rewrite ^(.*)/$ $1/index.php redirect; rewrite ^(.*)$ $1/index.php redirect; } # If the requested file didn't exist, then check for vBulletin rewrite # rules. (We check for the presence of the requested file first in order to # serve images properly.) if (!-f $request_filename) { # Forum rewrite ^/threads/.*$ /showthread.php?$args last; rewrite ^/forums/.*$ /forumdisplay.php?$args last; rewrite ^/members/.*$ /member.php?$args last; rewrite ^/blogs/.*$ /blog.php?$args last; rewrite ^/entries/.*$ /entry.php?$args last; # MVC rewrite ^/([^/]*\.php)(?:/(.*))?$ /$1?r=$2 last; rewrite ^/([^/]*)(?:/(.*))?$ /$1.php?r=$2 last; } } }