We use WordPress extensively – we self host the wordpress files on our own servers or with a 3rd party hosting company like Godaddy or 1&1 Internet.

For the most part WordPress works great but if you look under the hood there about a trillion files, not to mention a bunch of 3rd party plugins – the end result is that eventually something goes wrong and its hard to trouble shoot when it does. Often the end result is a complete reinstall of all files and database. Not fun. We’d rather be blogging.

The WordPress Admin Site Login Redirect Loop Error

We recently setup a new web site with a new WordPress Blog – lets call it example.com.

For some reason when we went to Login to the admin site (with the correct username and password) the login.php script would redirect back to wp-admin directory. Resulting in an endless loop and preventing us from logging in to the WordPress admin site.

The WordPress Redirect URL

Just to give you an idea, the URL after the redirect was http://www.example.com/blog/wp-login.php?redirect_to=http://www.example.com/blog/wp-admin

To cut a long story short and after trying many many different strategies to resolve this issue (and many hours) we finally came up with the solution:

The Solution

Simply paste @define(‘ADMIN_COOKIE_PATH’, ‘/’); to the very top of your WordPress wp-config.php file. (This file is in the root of your WordPress directory).

We finally found the answer by Googling various keywords but it took a while to come up with the right keywords that lead us to another user who had this same problem.

Cookies no doubt were the issue here but we got this error on all browsers and across multiple networks so it was in no way isolated to a single computer.
Clearing all cookies from the browsers also did not help, neither did deleting all plugins as some people suggested.

How to login to your WordPress admin site when all else fails to solve the redirect loop

One of the frustrating things about this problem was that we could not log back in to the admin site to try to resolve this problem by tweaking settings from within WordPress admin site.
Eventually we found a hack that got us in.

Wordpress login redirect loop error

After entering the username and password and hitting submit the WordPress admin site loads in the following sequence if you watch the URL:

http://www.example.com/blog/wp-login.php

http://www.example.com/blog/wp-admin

http://www.example.com/blog/wp-login.php?redirect_to=http://www.example.com/blog/wp-admin

(The last url bringing you back to where you started – not what you want)

As soon as http://www.example.com/blog/wp-admin appears hit the stop button on your browser so that the page stops loading.
Then click in the URL bar of your browser (which should still contain the URL http://www.example.com/blog/wp-admin) and hit enter to reload the page.
This then took us direct to the admin site no problem

Good luck

Posted on: Saturday, June 19th, 2010 - 2 years, 11 months ago

2 Responses to “WordPress Loop Problem: login.php Redirects to wp-admin”

  1. None of these fixes work for me. Entering @define(‘ADMIN_COOKIE_PATH’, ‘/’); in the -config.php file just places this text at the top of my website. The browser goes through the URL re-direct so quickly it’s not possible to interrupt it.

    Interesting that this problem only seems to occur when I upgrade!

  2. Mark Snape says:

    A customer of mine was having this problem with a brand-new 3.2 install. I could not reproduce in Google Chrome, but could not login in IE. As described above, after logging I was redirected back to the login page.
    I found a workaround which was to place the ‘meta’ login/logout link on the site and then tell the customer to use that instead of trying to go straight to wp-admin.
    Not happy with that, I continued to search and came across this page.
    I followed the instructions – with one exception – and it fixed the problem.

    The exception, and it is one to note when copying any code from a wordpress site is to replace smart quotes with single quotes. So, if you copy the code from above and paste into your editor you will find that the code has curved quote symbols. Look at the PHP lines already in your wp-config file and you will see that PHP needs single or double quotes around strings.

    Thanks for the tip. It seems to have worked for me and I hope I can save other’s frustrations by just copying the code.

Leave a Reply

This site uses KeywordLuv. Enter YourName@YourKeywords in the Name field to take advantage.