【发布时间】:2016-11-16 04:35:30
【问题描述】:
我在 nginx 上使用 PHP 框架实现 web 服务器,没有任何 index.html,网页工作正常,但一些脚本不起作用,它说“500 内部服务器错误”
这是服务器日志
2016/11/16 11:08:38 [错误] 2551#0: *738 重写或内部重定向周期,同时内部重定向到“/index.html”,客户端:27.131.251.6,服务器:www.foreverstore。 id,请求:“GET /kelontong/getKelontong HTTP/1.1”,主机:“192.168.70.86”
2016/11/16 11:09:20 [错误] 2551#0: *746 重写或内部重定向周期,同时内部重定向到“/index.html”,客户端:27.131.251.6,服务器:www.foreverstore。 id,请求:“GET /kelontong/getKelontong HTTP/1.1”,主机:“192.168.70.86”
2016/11/16 11:14:47 [错误] 5500#0: *4 重写或内部重定向周期,同时内部重定向到“/index.html”,客户端:27.131.251.6,服务器:www.foreverstore。 id,请求:“GET /department/ HTTP/1.1”,主机:“192.168.70.86”
2016/11/16 11:14:48 [错误] 5500#0: *6 重写或内部重定向周期,同时内部重定向到“/index.html”,客户端:27.131.251.6,服务器:www.foreverstore。 id,请求:“GET /department/getdepartment HTTP/1.1”,主机:“192.168.70.86”
2016/11/16 11:18:56 [错误] 5518#0:*4 重写或内部重定向周期,同时内部重定向到“/index.html”,客户端:27.131.251.6,服务器:www.foreverstore。 id,请求:“GET /department/getdepartment HTTP/1.1”,主机:“192.168.70.86”
2016/11/16 11:18:56 [错误] 5520#0:*8 重写或内部重定向周期,同时内部重定向到“/index.html”,客户端:27.131.251.6,服务器:www.foreverstore。 id,请求:“GET /department/getdepartment HTTP/1.1”,主机:“192.168.70.86”
2016/11/16 11:21:35 [错误] 5534#0: *3 重写或内部重定向周期,同时内部重定向到“/index.html”,客户端:27.131.251.6,服务器:www.foreverstore。 id,请求:“GET /department/getdepartment HTTP/1.1”,主机:“192.168.70.86”
这是我的 nginx 主机配置文件
server {
listen 443 ssl http2;
root /bwi/foreverstore.id;
index index.html index.htm index.php;
server_name www.foreverstore.id ;
ssl_certificate /etc/nginx/ssl/foreverstore.crt;
ssl_certificate_key /etc/nginx/ssl/foreverstore.key;
location / {
try_files $uri $uri/ /index.html;
# try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
allow ::1;
deny all;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_param MAGE_RUN_CODE default;
fastcgi_param MAGE_RUN_TYPE store;
}
}
如果你们知道如何解决这个问题,我将不胜感激 干杯。
【问题讨论】:
-
我认为原因是因为一旦
$uri和$uri/失败,它会重定向到/index.html,然后再次通过try_files并在$uri和$uri/失败然后重定向到/index.html。你明白了......尝试将/index.html更改为/index.php,这样如果在$uri和$uri/失败,它将默认为您的\.php$块 -
我也尝试过这种方法,但它仍然没有解决我的问题,它只是重定向到我的主页,我想要看到我的引擎像我的其他服务器(apache2)一样工作,比如@987654321 @(它在 apache2 上显示我的引擎)但在 nginx 上,它只是错误/重定向到主页
-
如果它重定向到您的主页,那么您最初的重定向循环问题就解决了,因此这是您的问题的解决方案。除此之外,您还需要在后端进行配置,或者提出一个新问题,其中包含更多详细信息,描述您想要实现的目标、您尝试过的内容、您期望发生的事情以及实际发生的事情。
-
你是怎么解决这个问题的?