Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress https 'redirected you too many times.' error

I am hosting a wordpress site on AWS and am transitioning from http to https. After reading some resources from online I added this line to the wp-config.php file:

define('FORCE_SSL_ADMIN', true);

Now when i try to access the /wp-admin/ page I get the xx.xx.com redirected you too many times. The all of the other pages work, it is only the admin panel that is not working.

like image 739
Fahad Jameel Avatar asked Jan 06 '23 21:01

Fahad Jameel


1 Answers

For anyone coming here like me being behind a reverse proxy that handle the SSL stuff, it took me a while but I could find the documentation where it states what has to be done:

https://codex.wordpress.org/Administration_Over_SSL

It states to add an if in the wp-config:

// in some setups HTTP_X_FORWARDED_PROTO might contain 
// a comma-separated list e.g. http,https
// so check for https existence
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
   $_SERVER['HTTPS']='on';

As I don't like to touch the config (mostly because I forget I touched it) I tried to find a more elegant way of doing it:

https://wordpress.org/plugins/ssl-insecure-content-fixer/

I have tried with this plugin and it works.

like image 84
Panthro Avatar answered Jan 15 '23 14:01

Panthro