【问题标题】:How to convert Apache rewrite rules to nginx如何将 Apache 重写规则转换为 nginx
【发布时间】:2018-05-06 19:57:57
【问题描述】:
<LocationMatch "^/(starwars|ironman|hulk|blackwidow|thor|loki)($|/|\?)">
        RewriteCond "%{REQUEST_FILENAME}"       !-f
        RewriteCond "%{REQUEST_FILENAME}"       !-f
        RewriteRule "^(.+)" "https://www.example.com%{REQUEST_URI}" [P]
</Locationmatch>

这是我的 apache 重写规则,我按照谷歌的建议尝试了几个选项。但这对我不起作用。有什么帮助吗?

【问题讨论】:

    标签: apache mod-rewrite nginx


    【解决方案1】:

    我尝试在 nginx 中使用 if 条件(尽管不建议这样做),它对我有用。

    location ~* ^/(starwars|ironman|hulk|blackwidow|thor|loki)($|/|\?)>
        root /location/of/files/;
        if (!-e $request_filename) {
        proxy_pass https://www.example.com;
        }
    

    【讨论】:

      猜你喜欢
      • 2016-06-18
      • 1970-01-01
      • 1970-01-01
      • 2014-06-30
      • 2016-08-09
      • 1970-01-01
      • 1970-01-01
      • 2013-01-23
      相关资源
      最近更新 更多