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 whether the redirect loop is fixed.
I hope it fixed your redirect loop, I know how frustrating it can be!
Next: Cloud Hosting and a Powerful New AI called Maxine
Exactly as you said, after struggling with all other tutorials, this was the one that saved my day. Thank you very much!
You’re welcome, I’m very happy it solved your problem.
OMG. YOU FIXED IT! I’m seriously pulling my hair out. I CAN’T BELIEVE this worked! NOTHING else did! THANK YOU THANK YOU THANK YOU!!!!
You know what….! You are a genuis! I was really pulling my hair out, and just a simple line of code fixed it!!!! Thanks a bunch buddy!
THIS IS AMAZING!
Arador – Thank you a 1000 times!
Like everyone here trying to update the siteurl , homeurl and even the htaccess nothing worked. This did!
Great explanation on why and then the fix!
The provided solution didn’t help for me. However, I’ve come accross another blogpost, which recommended to disable the template redirect filter in WordPres – that did the fix for me:
// insert this line in functions.php
remove_filter(‘template_redirect’, ‘redirect_canonical’);
Thank you thank you thank you!!! Worked perfectly. 🙂
ducking awesome!
The tip is very useful with me. Tks u a million <3
Thank you! As you said the other solutions suggested did not work for me. But this did!
Thank you for this fix, especially since my WP site is running on Linux and I’m using Nginx as a reverse proxy.
I’m bookmarking this page. I appreciate you. Happy New Year to you and yours.
Thank you very much – resolved a frustrating evening.
You’re welcome, I know that frustration well!
I looked high and low and tried everything to get my wp admin login to stop redirecting too many times …
I was about to give up when I found your code and wah-la it worked !!
Thank you – Thank you !! Your a Gem!
Thanks a lot for this!
Really works! Thanks a lot.
First one that worked. I had to guess at what the comment section was, though.
Yet another site saved with this advice! In my case, it had something to do with CloudFlare adding SSL, but this trick fixed it.
Thanks!
Thanks Very much. I have been looking for the solution everywhere and here only i find it.
You saved my day…Thanks a lot