以下是我现有的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配置?
想明白了:nginx根指令只需要更改为apache文件夹。