Login to WordPress redirects to another wp-admin

If  your WP login redirects to a different installation of WordPress and you cannot log in to the correct wp-admin:

In my case it was a matter of exporting a blog from WPMU to a stand alone blog on another server to replicate the entire wordpress installation with all of the posts and pages intact.

Apparently it exported the blog address. I could access the wordpress blog as a user, but couldn’t login as the admin.

Another time I changed the Admin->Settings->General->”Wordpress address (URL)” from a domain name to an IP/directory which threw it into a tizzy. Every time I tried to log in to it would redirect me. No way to fix this in WordPress Admin panel.

This fixed it:
Edit the WordPress Database on the server you’d like to login to. Find out by looking at your /wp-config.php file. Then using Cpanel then PHPMyAdmin, open the database and go to the table wp_options->option_name and the value is the blog that it’s redirecting to!
Change this value to the WP install that you’d like to log in to, even using http://174.34.141.10/~myaccount if you have to.

If this doesn’t actually finish a successful login, and it did make the redirect go to the proper blog, but the redirect is still there it could be caused by a config file, not the database.

Alternatively, this may help:

Defining the cookie stuff:

define(‘ADMIN_COOKIE_PATH’, ‘/’);
define(‘COOKIE_DOMAIN’, ”);
define(‘COOKIEPATH’, ”);
define(‘SITECOOKIEPATH’, ”);

Worked for me too – 2.7, with multiple domains and blogs.

29 Comments

  1. Mike says:

    Thanks for the tip. It totally saved my ass.

  2. Rick says:

    This option_name value was the problem for me. Thanks for the fix!

  3. THank you says:

    Very useful!

  4. Astrid says:

    Thnx!! I tried it first on the official wordpres site but they seem to think such a thing never happens or something.

    Your solution worked so i’m very glad!

    Thnx again!

    Hugs from Holland, Astrid.

  5. kindredmildred says:

    Hey, many thanks. Burned the midnight oil to solve this one but you nailed it man!

  6. Thanks mate, I’ve been searching for ages for this

  7. Pradeep Sinha says:

    many many thanks mate, it helped me …. cheers

  8. Geovanny says:

    Thanks for the tip!. This by far a horrible thing that WordPress does. No reason why this should be hard coded in the database. It makes for migrating sites a royal pain in the @##@. Anyway, great job sharing this information.

  9. Tamatea says:

    Thanks a lot for this information

  10. Yotam says:

    Thanks for directing me to the problem in the database. I “imported” settings from one theme to another and bham! can’t log in to the right blog.

  11. This post saved my blog! says:

    Thank you so much for posting this info. I was freaking out when my wp-admin kept redirecting me to another location on my web domain and I had no way of accessing my blog via the WP dashboard. In addition while searching for fixes this was the only site that mentioned it was a problem with the actual database and not some weird .htaccess file redirect.

    • GoogleThem says:

      Wow, these comments make me look forward to another baffling incident which makes me struggle for hours to find a simple solution that takes minutes to fix 😉

  12. Matt says:

    Excellent – thanks!

  13. Patricia says:

    I love U!

  14. Dave says:

    Well done, sir.

  15. Gregg says:

    Thanks man! You saved me from throwing my computer through the wall!
    great info.

  16. Alejandro says:

    OMG i cant thank you enough!!!!

    i was just about to recreate an entire site because the wp-admin redirected me to an old domain i transfered the site from

    I hope you to live a long and happy life !!

  17. Ralph says:

    Yep! You da man.

  18. Stephan says:

    Lifesaver!!!!!

  19. bigyan says:

    wow it works and solves my tons of problem .Thank you so much

  20. Lima Romeo says:

    Many thanks, helped me to solve the wp-admin redirect after changing a wordpress site to another domain…..cheers….!!! Put some adsense codes on this site so we could give you some click s mate….;-)

  21. Jason C. says:

    Thanks for posting this. Wild West automatically generated my WordPress Database and was redirecting my login to the root URL. Your instructions helped me solve it. THANK YOU!

  22. thawet says:

    The first fix is sloved my problem.thanks……

  23. Todd says:

    Thanks a ton, this was incredibly helpful.

    Best,

    Todd

  24. 2Cups says:

    Greetings from Ohio! I’m bored at work so I decided to check out your site on my iphone during lunch break. I love the information you provide here and can’t
    wait to take a look when I get home. I’m surprised at how quick your blog loaded on my mobile .. I’m not even using
    WIFI, just 3G .. Anyways, awesome site!

  25. Alan Lee says:

    Thank you very much for this awesome tip. Editing the database options did the trick for me.

  26. Open to FTP control panel, browse for your theme functions.php file and add this two line
    immediately after the initial “<?php" line.

    update_option('siteurl','http://example.com/blog&#039;);
    update_option('home','http://example.com/blog&#039;);

    That's It, Save and now check your login.

Leave a comment