Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nginx - rewrite or internal redirection cycle while internally redirecting to "/index.html" [closed]

I cannot figure out why this error is happening: "rewrite or internal redirection cycle while internally redirecting to "/index.html""

I found a similar post and tried various recommendations based on what I read, but to no avail.

Here is my nginx config. Any help would be appreciated!

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html/public;
    index index.php;

    # Make site accessible from http://localhost/
    server_name ourdomain.com;

    location @handler {
        rewrite / /index.php
    }

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ .php$ {
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        # add the following line in for added security.
        try_files $uri =403;
    }
}
like image 326
kambythet Avatar asked Feb 25 '14 18:02

kambythet


2 Answers

Okay resolved. The issue was the

location @handler {
    rewrite / /index.php
}

Removed it and all is well again.

like image 167
kambythet Avatar answered Nov 15 '22 00:11

kambythet


This is better asked on Server Fault.

It looks like /index.html is matching /index.php?$query_string, which is being passed to php, and I'm guessing redirecting from there back to /index.html.

I can't really give you anymore information than that though since your question doesn't specify the request URL and I know nothing about possible redirects in your app.

like image 36
Kyle Avatar answered Nov 14 '22 23:11

Kyle