Php Nginx重写或内部重定向循环,同时内部重定向到/index.html“;
我使用Php框架在nginx上实现web服务器,没有任何index.html,网页工作正常,但一些脚本不工作,它显示“500内部服务器错误” 这是服务器日志 2016/11/16 11:08:38[错误]2551#0:*738内部重定向到“/index.html”时的重写或内部重定向周期,客户端:27.131.251.6,服务器:www.forevestore.id,请求:“GET/kelonton/getkelonton HTTP/1.1”,主机:“192.168.70.86” 2016/11/16 11:09:20[错误]2551#0:*746在内部重定向到“/index.html”时重写或内部重定向循环,客户端:27.131.251.6,服务器:www.forevestore.id,请求:“GET/kelonton/getkelonton HTTP/1.1”,主机:“192.168.70.86” 2016/11/16 11:14:47[错误]5500#0:*4内部重定向到“/index.html”时的重写或内部重定向周期,客户端:27.131.251.6,服务器:www.forevestore.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.forevestore.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.forevestore.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.forevestore.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.forevestore.id,请求:“GET/department/getdepartment HTTP/1.1”,主机:“192.168.70.86” 这是我的nginx主机配置文件Php Nginx重写或内部重定向循环,同时内部重定向到/index.html“;,php,nginx,web,Php,Nginx,Web,我使用Php框架在nginx上实现web服务器,没有任何index.html,网页工作正常,但一些脚本不工作,它显示“500内部服务器错误” 这是服务器日志 2016/11/16 11:08:38[错误]2551#0:*738内部重定向到“/index.html”时的重写或内部重定向周期,客户端:27.131.251.6,服务器:www.forevestore.id,请求:“GET/kelonton/getkelonton HTTP/1.1”,主机:“192.168.70.86” 2016/11
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;
}
}
如果你们知道如何解决这个问题,我会感谢你们
干杯。我认为try\u files行应该是这样的:
try_文件$uri$uri/index.html代码>由于您没有使用所述的任何html文件,请更改根位置块:
location / {
try_files $uri $uri/ =404;
}
您还必须在php块中包含一个try文件,因此当它失败时,它将转到那里,而不是寻求重定向:
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;
try_files $uri $uri/ =404;
}
由于您声明:error\u第404页/404.html代码>您还可以添加404位置:
location = /404.html {
root /usr/share/nginx/html/;
internal;
}
这将停止那些丑陋的重定向循环。我已经在使用该脚本,但它仍然不起作用。我没有使用任何html文件,只是php framewrokI我想原因是一旦$uri
和$uri/
失败,它会重定向到/index.html
,然后它再次运行try_文件
,在$uri
和$uri/
失败,然后重定向到/index.html
。你明白了。。。尝试将/index.html
更改为/index.php
,这样,如果在$uri
和$uri/
失败,它将默认为您的\.php$
块。我也尝试过该方法,但它仍然没有解决我的问题,它只是重定向到我的主页,我想看到我的引擎与我的其他服务器一样工作(apache2)比如(它在apache2上显示我的引擎)但在nginx上,它只是错误/重定向到主页如果它重定向到你的主页,那么你最初的重定向循环问题就解决了,因此这就是你问题的解决方案。任何超出你需要在后端配置的内容,或者问一个新问题,其中包含更多详细信息,描述你正在尝试实现的目标、你尝试了什么、你做了什么你期望发生什么,实际发生了什么。你是如何解决这个问题的?