2013-03-25 16 views
0

我试图创建一个nginx的重写,我似乎无法获得工作非常正确...nginx的先进重写

我想要做的事:

改写:
bleh.com/productPage/productname/?action=yes&id=12

到:
bleh.com/productPage/index.php?product=productname&action=yes&id=12

到目前为止,我已经得到最接近的是:

location/{ 
rewrite ^/productPage/(.*)/(.*)$ /productPage/index.php?$1 last; 
} 
location ~ \.php$ { 
fastcgi_index ... (and the rest of the working fastcgi config) 

但是我也只是在打404的..

任何帮助,将不胜感激。

回答

0

尝试:

location /productPage/ { 
    rewrite ^/productPage/(.*)/$ /productPage/index.php?product=$1 index.php last; 
} 

注:the rewrite directive正则表达式匹配上the $uri variable其中不包括参数,该参数将被自动除非你结束替代路径与?

+0

曾为连接到rewriten网址... 谢谢! – user2208647 2013-03-25 20:11:11