public
Created

  • Download Gist
nginx_rewrite.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
location / {
index index.html;
root /path/to/site;
 
#If the file exists don't do any processing
if (-e $request_filename)
{break;}
 
#A rewrite rule
if (-e $request_filename.php) {
#rewrite any other page to page.php
rewrite ^/([^\.]+)$ /$1.php last;
}
 
#If the file exists on the old site, redirect there
if (-e /path/to/old/site$document_uri)
{
rewrite ^.*$ http://oldsite.domain.co.uk$document_uri permanent;
}
 
}
 
error_page 404 /404.php;

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.