Thursday, October 28, 2010

Correct the WordPress site URLs

I accidentally changed the WordPress HOME and SITEURL to the root of my domain, which is pointing nowhere (default IIS start page) and I locked myself out of the WordPress admin.  After  a few minutes of research I managed to get the site running and login back to admin area again.

1. The first method is so easy so I figure I should give it a try:
->modify the wp-config.php file to add two lines:
define('WP_HOME','http://my.website.com/correctlocation');
define('WP_SITEURL,'http://my.website.com/correctlocation');
Problem: after you did above, the site is running and you will be able to login to the admin interface. However, the Home and site URL values are no longer available for editting (they are greyed out) through the general settings.

2. I restored the wp-config.php to it was and tried the second method. which works great.
->modify the current active theme's functions.php file, to add two lines right after <?php line:
update_option('siteurl','http://my.website.com/correctlocation');
update_option('home', 'http://my.website.com/correctlocation');
Site is running and had no problem to login, the general setting shows the correct urls for my site and home. save the change and logout.
**Important: Remove the two lines you just added from functions.php. Put the file back where it belongs. login and logout and everything should be fine.

3. there are other methods, like to edit directly in database. I did not try it. Hopefully I will not need it. Do a search "Changeing the site URL" in WordPress Codex will lead to more answers.

No comments:

Post a Comment