url rewriting - How to write a url rewrite in nginx? -
i want people type in http://www.myweb.com/like/1234456 redirect http://www.myweb.com/item.php?itemid=1234456
i wrote in config doesn't work.
location = ^~/like/ { rewrite ^1234456 ../likeitem.php?item=1234456break; return 403; }
this test. haven't used $ matching yet.
i restart ngnix server still.. doesn't redirect.
the code above not work because of missing $ , poor use of return command. code above works nginx, including version 0.8.54.
format below : desiredurl actual url nginx_rule
they must inside location / {}
http://example.com/notes/343 http://example.com/notes.php?id=343 rewrite ^/notes/(.*)$ /notes.php?id=$1 last; http://example.com/users/blackbenzkid http://example.com/user.php?username=blackbenzkid rewrite ^/users/(.*)$ /user.php?username=$1 last; http://example.com/top http://example.com/top.php rewrite ^/top?$ /top.php last;
complex , further
http://example.com/users/blackbenzkid/gallery http://example.com/user.php?username=blackbenzkid&page=gallery rewrite ^/users/(.*)/gallery$ /user.php?username=$1&page=gallery last;
Comments
Post a Comment