【问题标题】:convert folder rewrite rule from apache to nginx将文件夹重写规则从 apache 转换为 nginx
【发布时间】:2015-11-06 23:12:31
【问题描述】:

这些是我现有的 Apache htaccess 规则:

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteBase /
   RewriteRule    ^$ myapp/webroot/    [L]
   RewriteRule    (.*) myapp/webroot/$1 [L]
</IfModule>

在这里阅读其他主题后,我在我的 nginx 服务器块配置中使用了这一行来启用重写:

location / {
root /var/www/example.com/html;
try_files $uri $uri/ /index.php$is_args$args;
}

所以基本的重写现在可以工作,但问题是,位于上述 apache 文件夹中的文件现在在根级别(不是从提到的文件夹)被调用,然后导致这些文件出现 404 错误。

如何将我的 Apache 规则正确导入到我的 nginx 配置中?

【问题讨论】:

    标签: apache .htaccess mod-rewrite nginx


    【解决方案1】:

    想通了: 只需将 nginx 根指令更改为 apache 文件夹即可。

    【讨论】:

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