How to Fix the Too Many Redirects Error in WordPress

QUESTIONS CENTRECategory: apacheHow to Fix the Too Many Redirects Error in WordPress
ZENHOST Support Staff asked 3 years ago

If you find this post it means you’ve attempted all other tutorials about “How to Fix Too Many Redirects in WordPress” and you’re probably pulling your hair out, or what’s left of it.

Well there’s one thing pretty much every other tutorial leaves out, and I’m going to save your day and make your pain go away.

If you experienced the too many redirects error after installing WordPress with https enabled and then you change the http to https in general settings then this is probably the fix you need, but only if you’re using an nginx ssl terminator to an Apache http localhost.

You’ll know whether you are or not because in your nginx host file you’ll have this, and if you don’t have it then that could be one more reason your stuff is broken:

proxy_set_header X-Forwarded-Proto https;

So if clearing your cookies and cache doesn’t work like every other tutorial tells you and the above nginx  setup sounds familiar then edit your

wp-config.php

file and add this code to it just after the comments section.

if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') $_SERVER['HTTPS']='on';

and you’re done, give it a try now and see the redirect loop is fixed.