我正在尝试在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 :(得分:0)
尝试:
location /productPage/ {
rewrite ^/productPage/(.*)/$ /productPage/index.php?product=$1 index.php last;
}
注意:the rewrite directive匹配the $uri variable上不包含参数的正则表达式,参数将自动附加到重写网址,除非您使用?
结束替换路径