【发布时间】:2019-04-09 08:00:40
【问题描述】:
我正在从 .htaccess 迁移到 nginx.conf 文件,但迁移规则无法按预期工作。 这是我要迁移到 nginx 的 .htaccess 的内容。
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|assets)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]
这是我迁移的 nginx.conf 的内容:
index index.php
location / {
rewrite ^(.*)$ /index.php?$1 break;
}
请让我知道这有什么问题以及如何让 nginx conf 文件正常工作。
问候。玉铭
【问题讨论】:
-
您在
index语句的末尾缺少;。另外,尝试将rewrite语句替换为:try_files $uri $uri/ /index.php?$uri; -
感谢您的评论。试过了,效果很好。
标签: .htaccess ubuntu nginx mod-rewrite npm