问题描述:
网站首页显示正常,但点击产品或栏目链接都报500错误,Nginx日志显示错误:
2018/05/14 17:52:28 [error] 13566#0: *8 rewrite or internal redirection cycle while processing "/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/customer/ajax", client: 127.0.0.1, server: www.emall.com, request: "GET /customer/ajax?currentUrl=http%3A%2F%2Fwww.emall.com%2F&product_id= HTTP/1.1", host: "www.emall.com", referrer: "http://www.emall.com/"
问题解决:
正确的Nginx配置:(在Yii2中使用PrettyURL这样配置是可以的)
[webadmin@centos7 eltmall] #24> vim /etc/nginx/nginx.conf
......
......
location / {
# 各种尝试之后所得的结果,就是一句代码,OK!
try_files $uri $uri/ /index.php?$args;
}
......
......
错误的Nginx配置:(至少在我的机器中是错误的)
[webadmin@centos7 eltmall] #24> vim /etc/nginx/nginx.conf
......
......
location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
}
}
......
......
[webadmin@centos7 eltmall] #24>
最后上个图:
