【问题标题】:htaccess to nginx simple url rewrite conversionhtaccess 到 nginx 简单的 url 重写转换
【发布时间】:2015-03-24 16:17:33
【问题描述】:

我正在尝试将以下 .htaccess 重写为过去 2 小时,首先尝试了所有在线转换器但没有运气,还尝试查看转换示例但在任何地方都没有找到此转换:^system.*

如果有人可以帮助我,我将不胜感激。

RewriteEngine On

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

【问题讨论】:

  • 向我们展示您的尝试 - 它可能只需要一个小修复? ^system.*(和^system一样)只是一个简单的正则表达式,在nginx中大概也一样吧?

标签: apache .htaccess mod-rewrite nginx


【解决方案1】:

Apache 假定前导正斜杠。 Nginx 没有。

location ~* "^/system.*" {
    try_files $uri /index.php$uri;
}

另外,不要使用那些在线转换器。在 Nginx 中有更好的处理文件存在的方法,他们没有考虑到这些方法。看看这个:

http://wiki.nginx.org/Pitfalls#Check_IF_File_Exists

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-29
    • 2017-12-18
    • 2017-06-06
    • 1970-01-01
    • 1970-01-01
    • 2011-08-21
    • 2015-11-11
    相关资源
    最近更新 更多