Apache:帮助转换.htaccess

时间:2010-11-30 15:20:54

标签: apache .htaccess mod-rewrite nginx

我正在尝试将以下。 htaccess 重写规则转换为相应的 NGINX 格式。

# Redirect /signup/PLANNAME or /signup/PLANNAME/ --> /signup/index.php?account_type=PLANNAME
RewriteEngine on
RewriteRule ^signup/([A-Za-z]+)/?$ /signup/index.php?account_type=$1 [NC,L]

我尝试使用以下NGINX规则,但它无效。

rewrite  ^signup/([A-Za-z]+)/?$ /signup/index.php?account_type=$1  last;

知道我在做什么与NGINX一起做错了吗?查看official documentation并不是很有用,因为文档不是很完整。

2 个答案:

答案 0 :(得分:0)

由于您不在.htaccess文件中,因此必须使用绝对路径。就这样:

rewrite  ^/signup/([A-Za-z]+)/?$ /signup/index.php?account_type=$1  last;

答案 1 :(得分:0)

我发现了问题,我在开头时错过了正斜杠(/)。

答案:

rewrite  ^/signup/([A-Za-z]+)/?$ /signup/index.php?account_type=$1  last;