[英]Nginx rewrite last not works
I have problem with rewrite url. 我重写网址有问题。 PERMANENT works fine. 永久工作正常。 but when I change to LAST - it not works. 但是当我更改为LAST时-它不起作用。 phpinfo shows old values. phpinfo显示旧值。
http://site.com/?parent_id=10 -> http://site.com/parent/10 http://site.com/?parent_id=10- > http://site.com/parent/10
if ($args ~ "parent_id=(.*)") {
set $parent $1;
set $args '';
rewrite ^/$ /parent/$parent permanent;
}
It should be internal as future rewrites will convert /parent/10 to Yii framework url rules. 它应该是内部的,因为将来的重写会将/ parent / 10转换为Yii框架url规则。 I rewriting old website to use YiiFramework and would like to leave old urls like they are. 我重写旧网站以使用YiiFramework,并希望保留旧网址。
Thanks, Alex 谢谢,亚历克斯
Using IF IS EVIL . 使用IF IS EVIL 。 Attached are some URL re-writes. 随附一些URL重新编写。 Also remove the set
etc.. no need for strings! 还删除set
等。不需要字符串!
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;
To answer your question . 回答你的问题 。 You want something along the lines of: 您需要以下方面的东西:
rewrite ^/parent/(.*)$ /parent.php?id=$1 permanent;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.