Dan Dan - 9 months ago 50
Apache Configuration Question

htaccess to nginx rewrite rules

I've recently moved from an Apache to a Nginx webserver, however a script seems to have issues due to rewrite rules that are not properly working.

I've tried winginx.com, a website that offers conversion from htaccess to nginx however it does not really seem to work

The rewrites are the following:

RewriteRule ^people/([0-9]+)$ people.php?p=$1 [NC,L]
RewriteRule ^user/([0-9]+)$ profile.php?id=$1 [NC,L]
RewriteRule ^user/([0-9]+)/photo_upload$ profile.php?id=$1&photo_upload=true [NC,L]
RewriteRule ^index.php?login/?$ index.php?login [NC,L]
RewriteRule ^visitors/?$ visitors.php [NC,L]

Some expert help would be greatly appreciated, thank you

Answer Source

These rewrites should work:

rewrite ^people/([0-9]+)$ /people.php?p=$1 last
rewrite ^user/([0-9]+)$ /profile.php?id=$1 last
rewrite ^user/([0-9]+)/photo_upload$ /profile.php?id=$1&photo_upload=true last
rewrite ^index.php\?login/?$ /index.php?login last
rewrite ^visitors/?$ /visitors.php last

Add them either to you main location, or out of all location blocks.