Linux – Nginx “rewrite or internal redirection cycle while internally redirecting to “/index.html”

linuxnginx

So here is my problem: I have the same problem with every file I try to access. It always sends me back to index.html or shows me an 500 server error. The error log gives me: "rewrite or internal redirection cycle while internally redirecting to "/index.html"

here is my config:

server {
    listen   80;


    root /var/www;
    index index.php index.html index.htm;

    server_name _;

    location / {
            try_files $uri $uri/ /index.html;

    }

    error_page 404 /404.html;

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root /var/www;
    }

    # pass the PHP scripts to FastCGI server listening on the php-fpm socket
    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;


    }

Whats the problem?

Best Answer

All your requests is matching by "location /" (except *.php scripts and 50x.html). So, it checks index.html on such requests, it can`t find any file and goes to /index.html (last parameter used for redirect).

What the case do you want?