Solving The WordPress Login Redirect Loop Problem
Recently I’ve been working on a new project as part of a development team. After a recent Git merge I found that I was unable to save any changes on WordPress posts and pages. I logged out of the site and cleared cache but then found I was unable to login. When I entered my details and submitted the form all that would happen is that I would be redirected back to the login page.
I read about several possible reasons for this and tried out several of the fixes but nothing worked. I put my Sherlock cap on and started checking the commits. It turns out the culprit had been hidden away in an old branch that only recently got committed.
It was inside the .htaccess file:
php_value upload_max_filesize 20MB
php_value post_max_size 25MB
php_value memory_limit 30MB
php_value max_execution_time 90
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Did you spot it? Kudos if you did! The culprit was the three PHP values that specify MB. PHP expects those to just say M as specified in the shorthand byte value note. After removing those naughty B’s I was able to login and save updates again. Here’s the working version:
php_value upload_max_filesize 20M
php_value post_max_size 25M
php_value memory_limit 30M
php_value max_execution_time 90
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Comments: None so far...be the first!