Wednesday, 28 August 2013

How to write a url rewrite in nginx? # set

location / {}

http://site.com/notes/343
http://site.com/note.php?id=343

rewrite ^/notes/(.*)$ /notes.php?id=$1 last;

http://site.com/users/BlackBenzKid
http://site.com/user.php?id=1

rewrite ^/users/(.*)$ /user.php?username=$1 last;

http://site.com/top
http://site.com/top.php

rewrite ^/top?$ /top.php last;

Complex and further

http://site.com/users/BlackBenzKid/gallery
http://site.com/user.php?username=1&page=gallery

rewrite ^/users/(.*)$/gallery /user.php?username=$1&page=gallery last;

No comments:

Analytics and Statistic

Blog Archive