[英]Nginx rewrite last not works
我重寫網址有問題。 永久工作正常。 但是當我更改為LAST時-它不起作用。 phpinfo顯示舊值。
http://site.com/?parent_id=10- > http://site.com/parent/10
if ($args ~ "parent_id=(.*)") {
set $parent $1;
set $args '';
rewrite ^/$ /parent/$parent permanent;
}
它應該是內部的,因為將來的重寫會將/ parent / 10轉換為Yii框架url規則。 我重寫舊網站以使用YiiFramework,並希望保留舊網址。
謝謝,亞歷克斯
使用IF IS EVIL 。 隨附一些URL重新編寫。 還刪除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;
回答你的問題 。 您需要以下方面的東西:
rewrite ^/parent/(.*)$ /parent.php?id=$1 permanent;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.