如何将Apache重写规则转换为nginx

时间:2017-11-22 23:49:41

标签: apache mod-rewrite nginx

<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重写规则,我尝试了谷歌建议的几个选项。但这对我没有用。有什么帮助吗?

1 个答案:

答案 0 :(得分:0)

我尝试在nginx中使用if条件(尽管没有建议)并且它对我有效。

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