Apache to NGINX 重写问题



我正在尝试将此 apacheReWriteRule转换为 NGINX,但它似乎不起作用。

阿帕奇规则:RewriteRule ^([A-Za-z0-9_-]+).php$ index.php?pagename=$1 [NC,QSA]

NGINX(不工作(:location / { rewrite ^/([A-Za-Z0-9_-]+).php? /index.php?pagename=$1; }

我确实在位置块中有 NGINX 规则。

我在这里错过了什么?我查看了其他类似的问题,但没有找到足够合适的线索来解决问题。感谢您的帮助。

使用转换器:

server {
server_name example.com;
rewrite ^/([A-Za-z0-9_-]+).php$ /index.php?pagename=$1;
}

事实上,许多重写更容易,只需将rewrite放在server {}上下文中(不需要多余的location(。

最新更新