How to Fix Wrong Path to WordPress Site Address, When Error Was Done in Admin Settings?

You had developed a WordPress site in a folder on your hosting account. Let’s say it was www.yourdomain.com/site/. Then it’s ready to be published and you are changing wordpress address to point to the root domain, to yourdomain.com. You copy your index.php (and .htaccess) to the root, changing path to your /site/ folder. And you changed the path to your site in Admin / Settings, as described in WordPres Codex. But what if you put a wrong address in Admin?

Like instead of modifying Site address (URL) you deleted /site/ from WordPress address (URL). You will not be able to enter admin anymore. You may edit then your database in phpMyAdmin to set back correct pathes, but the easiest way I found to deal with it, is to disable .htaccess files in root and /site/ folders, then to open /site/wp-login.php file in your editor, like notepad. Find on top of the page:

require( dirname(__FILE__) . '/wp-load.php' );

And add following lines to fix the settings:

//FIXME: remove these lines once database updated
update_option('siteurl', 'http://www.domain.com/site' );
update_option('home', 'http://www.domain.com/site' );
 

Go to wp admin login page /site/wp-login.php and reload. You will have your login working back to normal. And you can put back .htaccess and you should delete database fix code from /site/wp-login.php. Then change the correct path in wp admin / settings. WordPress address (URL) is where your wordpress installation is stored and it may look like www.yourdomain.com/site. The second input below, Site address (URL), should be pointed to your site root, Site address (URL) – yourdomain.com. No slashes are needed at the end of URL.

This entry was posted in WordPress and tagged . Bookmark the permalink.

9 Responses to How to Fix Wrong Path to WordPress Site Address, When Error Was Done in Admin Settings?

  1. Marcelle says:

    haha…. this is a cool idea! :(

  2. Thank You so much. that worked :-)

  3. dammuozz says:

    Thank you!! It worked for me too…

    using the bookmark /site/wp-admin it wasn’t working!
    just make sure to login on /site/wp-login.php as you said :D

  4. Rooie says:

    Life Saver.

  5. jordan says:

    Thank you. Quick and easy solution. Saved me an hour at least.

  6. mary jane says:

    For a newbie.. who screwed it up. I type the wrong name in the settings and now another site comes up….May I please have a step by step approach please and thank you.

  7. shubham says:

    hey ,i changed the settings, where it was saying Site Domain name:
    i put a domain name that doesnt exist,and the site is getting redirected to the wrong link which doesnt exist… :( please help me,and i didnt had any files recovered of that server ,as people say….
    how to change back again?
    i cant even login as admin… :(
    it says page dont exist,because it redirects to the url that doesnt exist…. :( please help!!!!

  8. mickie says:

    you save my butt, pal :) )

    Thanks alot

  9. zacfoo says:

    thanks SOO much. You saved my butt at the end of a long hard day transferring site files to a new host. THANK YOU!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="">