【发布时间】:2014-12-12 09:25:12
【问题描述】:
我尝试转换这个 .htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\?*$ index.php?_route_=$1 [L,QSA]
到 NGINX
location / {
try_files $uri $uri/ /index.php?_route=$uri;
}
但不起作用
如果工作,您将在http://test.bktvnews.com/data/menu/footer 上看到 json 文件 http://test.bktvnews.com/data/
【问题讨论】:
-
我在 Apache 中看到了
_route_=,在 nginx 中看到了_route=。此外,Apache 仅在没有查询部分时才会重写。而且,仍然显示完整的 nginx 服务器配置。 -
顺便说一句,nginx 中的
$uri以/开头。 -
谢谢,我改变了这一点,但仍然无法正常工作你所说的 / 和 $url
-
他的意思是在 htaccess 中 $1 将是
data/menu/folder,但在 nginx 中 $uri 是/data/menu/folder- 这可能对您的应用程序很重要。你能告诉更多关于“不起作用”的信息吗?