【问题标题】:Apache: help converting .htaccessApache:帮助转换 .htaccess
【发布时间】:2011-05-17 22:46:17
【问题描述】:

我正在尝试将以下 .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 并不是很有帮助,因为文档不是很完整。

【问题讨论】:

    标签: apache .htaccess mod-rewrite nginx


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      我发现了问题,我缺少开头的正斜杠(/)。

      答案:

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

      【讨论】:

        猜你喜欢
        • 2011-04-16
        • 2011-05-17
        • 1970-01-01
        • 2015-06-29
        • 2011-04-23
        • 2010-10-29
        • 2015-10-23
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多