解决nginx 报错提示:rewrite or internal redirection cycle while internally redirecting to "/",

小咪咪 2022-08-06 10:27 67阅读 0赞

配置好nginx+php-fpm,访问首页,提示报错:

2015/01/14 23:04:39 [error] 10964#2788: *2 rewrite or internal redirection cycle while internally redirecting to “/“, client: 127.0.0.1, server: bk, request: “GET / HTTP/1.1”, host: “bk”

报错原因:index 指令导致,解决方法 把 try_files $uri $uri/ ;改成 try_files $uri $uri/ =404;

特别注意:=404的等于号和404之间不能有任何空格。

完整配置:bk.conf源码如下(如需转载,请标注原作者 default.fu@foxmail.com):

  1. server {
  2. listen 80;
  3. server_name bk;
  4. root d:/website/bk.com/www;
  5. index index.html index.htm index.php;
  6. location / {
  7. try_files $uri $uri/ =404;
  8. }
  9. location ~ \.php$ {
  10. fastcgi_pass 127.0.0.1:9000;
  11. fastcgi_index index.php;
  12. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  13. include fastcgi_params;
  14. try_files $uri =404;
  15. }
  16. #error_page 404 /404.html;
  17. # redirect server error pages to the static page /50x.html
  18. #
  19. error_page 500 502 503 504 /50x.html;
  20. #location = /50x.html {
  21. # root html;
  22. #}
  23. location ~ /\.(ht|svn|git) {
  24. deny all;
  25. }
  26. }

发表评论

表情:
评论列表 (有 0 条评论,67人围观)

还没有评论,来说两句吧...

相关阅读