fbpx

As WordPress developer like us, always face a problem. The Problem is called. Too Many Redirect or ERR_TOO_MANY.

Why this problem come?

Before that let’s learn why this error comes in. This error comes in because of Header X-Forwarded-Protocol . When WordPress is loading the browser its send a X-Forward data to browser. So you have setup a new SSL. After you active the SSL you are getting TOO_MANY_REDIRECT error. So in that time wordpress is sending 2 type of data. One is X-FORWARDED-PORTO http and X-FORWARDED-PORTO https. Because you have setup SSL and it’s redirecting to secure layer. Because of sending 2 type data to browser network. Browser get confuse and throw and error which is TOO_MANY_REDIRECT . This Problem can be cause by plugin too.

Solving and Explain

To solve this error it’s every easy. We just need to send the https data to the browser. For that we need to force to use send only X-FORWARDED-PROTO only https. So, We can just add a single line code to solve it.

in wp-config.php file add this code:

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

That’s it Problem Solved. So what is happening over here. The code is checking is the website is in SSL or not If it’s in SSL it will for the website to send header data in HTTPS. If it’s not over SSL then it will force send the header data to HTTP.

After Adding this if it’s don’t work. Please follow the other fix.

This solution is applicable for Apache and Nginx if still Nginx has problem Then add this code in that site nginx config:

proxy_set_header X-Forwarded-Proto https;

Other Fix

Some time this problem can be fix by clear server cache or wordpress cache or clear own browser cache or disable plugins(Some time it’s cause by plugins too).