2013-05-03 54 views
0

我有重寫URL的問題。 PERMANENT正常工作。但是當我改變到最後 - 它不起作用。 phpinfo顯示舊值。Nginx重寫最後不工作

http://site.com/?parent_id=10 - >http://site.com/parent/10

if ($args ~ "parent_id=(.*)") { 
    set $parent $1; 
    set $args ''; 
    rewrite ^/$ /parent/$parent permanent; 
} 

應該是內部未來將重寫/父母/ 10轉換爲Yii框架URL規則。 我重寫舊網站使用YiiFramework,並希望像他們一樣離開舊網站。

謝謝,亞歷克斯

回答

1

使用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;