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

12 COMMENTS

  1. Exactly as you said, after struggling with all other tutorials, this was the one that saved my day. Thank you very much!

  2. 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!!!!

  3. 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!

  4. 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!

  5. 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’);

  6. 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.

LEAVE A REPLY

Please enter your comment!
Please enter your name here