Have you ever getting an infinite loop in your WordPress wp-admin? You are not alone. Usually browser like Firefox and Chrome will give you an error saying that the website is not redirected properly.
Are you a Cloudflare user? If you are, this is the right place to find the fix. If not, unfortunately your issue might be different from what I’m going to share. But hey, you can still continue to read.
The issue is you are getting infinite loop in your admin dashboard, which is wp-admin, causing you to lose access to admin tools.
Causes of this WordPress problem
There are 2 causes I have identified according to my case.
- Flexible SSL mode in Cloudflare with HTTPS enforced on blog
- Full SSL mode in Cloudflare with HTTP enforced on blog
Flexible SSL with enforced HTTPS
When you are using Flexible SSL mode, Cloudflare will access your blog using HTTP, then forward the content to user using HTTPS.
Guess what will happen when you keep asking to access your blog using HTTPS (enforced) instead of HTTP?
Yes! Cloudflare will keep using HTTP and your server refuse to serve the request and keep redirecting it to HTTPS forcefully. That is where an infinite redirect loop occurs.
But hey! I have my homepage working fine! Only wp-admin doesn’t work.
You can jump to the solution below to find the answer.
Full SSL with enforced HTTP
In Full SSL, Cloudflare will access your website with using HTTPS, then transmit the content to user also using HTTPS. When you force your blog to load in HTTP, the same thing happen like explained above, instead Cloudflare insist to access your blog using HTTPS but your server will keep redirecting it to HTTP.
Solutions for WordPress wp-admin redirect loop issue
If you are using Flexible SSL, you need to make sure your website doesn’t enforce HTTPS on any pages. If you have your front pages loaded fine and only wp-admin is having the issue, stop configuring your domain via wp-config.php
define( 'WP_HOME', 'http://dausruddin.com' ); define( 'WP_SITEURL', 'http://dausruddin.com' );
Delete these lines. Why? Because wp-admin doesn’t use those settings. Instead it will take value of siteurl and home from your database under table of wp_options, or in simpler words, value from WordPress Address (URL) and Site Address (URL) under your General Settings.
If you are having difficulties to update those values in your database, you can use your theme’s functions.php instead. Basically paste the code below in your theme’s functions.php after changing respective values to a correct address
update_option( 'siteurl', 'http://dausruddin.com' ); update_option( 'home', 'http://dausruddin.com' );
Then reload the page a few times until your admin dashboard loaded fine. This will automatically update those values in your database as well. Don’t forget to remove those values after you got them working!
This is basically the opposite of solution mentioned above. You just need to enforce HTTPS instead and not HTTP.