Nginx + WordPress ERR_TOO_MANY_REDIRECTS

Fresh installs a WordPress on Windows for development, and hits the ERR_TOO_MANY_REDIRECTS error message?

Tested URL : http://localhost/index.php/wp-admin/install.php

Tested :

  1. PHP 7.1.10
  2. WordPress 4.8.3
  3. Nginx 1.12.1
  4. MySQL 5.7.17
  5. Windows 10
your-nginx\conf\nginx.conf

	upstream php {
		server 127.0.0.1:9999;
	}

	server {
		listen       80;
		server_name  localhost;

		root www/wordpress;
		
		location / {
			try_files $uri $uri/ /index.php?$args;
		}

		location ~ \.php$ {			
			include fastcgi.conf;
			fastcgi_intercept_errors on;
			fastcgi_pass   php;
		}

		location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
				expires max;
				log_not_found off;
		}
		
	}

Solution

The missing of the default php page caused the “too many redirect” error messages, to fix this, add index index.php;

your-nginx\conf\nginx.conf

	upstream php {
		server 127.0.0.1:9999;
	}

	server {
		listen       80;
		server_name  localhost;

		root www/wordpress;
		
		# fixed wordpress install ERR_TOO_MANY_REDIRECTS
		index index.php;
		
		location / {
			try_files $uri $uri/ /index.php?$args;
		}

		location ~ \.php$ {			
			include fastcgi.conf;
			fastcgi_intercept_errors on;
			fastcgi_pass   php;
		}

		location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
				expires max;
				log_not_found off;
		}
		
	}

References

  1. Nginx + WordPress recipes

About the Author

author image
mkyong
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.

Comments

Leave a Reply

avatar
newest oldest most voted
Lotus55
Guest
Lotus55

good artikel

stevanie
Guest
stevanie

still don’t understand

BandarQQ
Guest
BandarQQ

Nice post . thanks