【问题标题】:htaccess to nginx rewrite ruleshtaccess 到 nginx 重写规则
【发布时间】:2016-10-22 07:18:44
【问题描述】:

我最近从 Apache 迁移到 Nginx 网络服务器,但是由于重写规则无法正常工作,脚本似乎存在问题。

我试过 winginx.com,一个提供从 htaccess 到 nginx 的转换的网站,但它似乎并没有真正起作用

改写如下:

RewriteRule ^people/([0-9]+)$ people.php?p=$1 [NC,L]
RewriteRule ^user/([0-9]+)$ profile.php?id=$1 [NC,L]
RewriteRule ^user/([0-9]+)/photo_upload$ profile.php?id=$1&photo_upload=true [NC,L]
RewriteRule ^index.php?login/?$ index.php?login [NC,L]
RewriteRule ^visitors/?$ visitors.php [NC,L]

非常感谢一些专家的帮助,谢谢

【问题讨论】:

    标签: regex apache nginx


    【解决方案1】:

    这些重写应该可以工作:

    rewrite ^people/([0-9]+)$ /people.php?p=$1 last
    rewrite ^user/([0-9]+)$ /profile.php?id=$1 last
    rewrite ^user/([0-9]+)/photo_upload$ /profile.php?id=$1&photo_upload=true last
    rewrite ^index.php\?login/?$ /index.php?login last
    rewrite ^visitors/?$ /visitors.php last
    

    将它们添加到您的主要位置,或从所有位置块中。

    【讨论】:

      猜你喜欢
      • 2020-01-10
      • 2014-04-24
      • 2014-06-30
      • 2016-08-09
      • 1970-01-01
      • 2013-02-27
      • 2020-10-02
      • 1970-01-01
      • 2014-10-30
      相关资源
      最近更新 更多