【问题标题】:How can convert mod_rewrite rules to nginx rules如何将 mod_rewrite 规则转换为 nginx 规则
【发布时间】:2014-11-21 18:14:20
【问题描述】:

不转换。帮助

RewriteEngine on
RewriteCond $1 !^(index\.php|images|css/common|robots\.txt|sitemap\.xml|test\.html|sitemap\.xml)
RewriteRule ^(.*)$ /index.php/$1 [L]

【问题讨论】:

标签: apache mod-rewrite nginx


【解决方案1】:

尝试提高你的提问技巧。很高兴看到您尝试了一些方法,甚至检查了您的原始配置,但没有通过复制粘贴(重复条目...)寻求帮助。

自动化工具最多可以尝试应用预先准备好的配方或 Apache 和 nginx 规则之间的 1 -> 1 关系。

他们将无法理解您想要做什么,并且很可能不会为您提供最佳/最干净/最精简/最推荐的解决方案。

例如这里,@Cheery 工具甚至忽略了条件... -_-'

尝试以下方法:

location /index.php {
}

location /images {
}

location /css/common {
}

location /robots.txt {
}

location /sitemap.xml {
}

location /test.html {
}

location / {
    # Use 301 instead of 302 for permanent redirect
    return 302 $scheme://$host/index.php$request_uri;
}

【讨论】:

  • 感谢伯纳德的提示。我坐了几个小时来阅读常见问题解答,我意识到你不能做与我想要的不同的事情。对不起我的英语,也对​​不起你花时间。
猜你喜欢
  • 2011-01-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-27
  • 1970-01-01
  • 2015-02-17
  • 2017-07-15
  • 2015-09-09
相关资源
最近更新 更多