简体   繁体   中英

convert folder rewrite rule from apache to nginx

These are my existing Apache htaccess rules:

<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:

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.

How can I import my Apache rules properly into my nginx config?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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