简体   繁体   English

将文件夹重写规则从apache转换为nginx

[英]convert folder rewrite rule from apache to nginx

These are my existing Apache htaccess rules: 这些是我现有的Apache htaccess规则:

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

After reading the other topics here I used this line in my nginx server block config to enable rewrites: 在阅读完其他主题之后,我在nginx服务器块配置中使用了以下这一行来启用重写:

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

So basic rewrite works now but the problem is, files that sit in above mentioned apache folders now get called at root level (not from mentioned folders) which then results in 404 errors for these files. 因此,基本的重写现在可以工作了,但是问题是,位于上述apache文件夹中的文件现在在根级别(而不是从提到的文件夹中)被调用,这将导致这些文件出现404错误。

How can I import my Apache rules properly into my nginx config? 如何将我的Apache规则正确导入到我的Nginx配置中?

弄清楚了:仅需要将nginx root指令更改为apache文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM