in Web and Tech, Work

Changing a WordPress site URL

Of the several options presented by the WordPress Codex, this one has been my go to. So far, I’ve never had a hitch. This one has been extracted directly from the Codex page:

1. FTP to the site, and get a copy of the active theme’s functions.php file. You’re going to edit it in a simple text editor and upload it back to the site.

2. Add these two lines to the file, immediately after the initial “<?php” line.

update_option( 'siteurl', 'http://example.com' );
update_option( 'home', 'http://example.com' );

Use your own URL instead of example.com, obviously.

3. Upload the file back to your site, in the same location. FileZilla offers a handy “edit file” function to do all of the above rapidly; if you can use that, do so.

4. Load the login or admin page a couple of times. The site should come back up.

Important! Do not leave those lines in the functions.php file. Remove them after the site is up and running again.

Note: If your theme doesn’t have a functions.php file create a new one with a text editor. Add the php tags and the two lines using your own URL instead of example.com:.

<?php
update_option('siteurl','http://example.com');
update_option('home','http://example.com');
?>

Upload that to your theme directory. Remove the lines or the remove the file after the site is up and running again.

 

For more of the available options, go to: http://codex.wordpress.org/Changing_The_Site_URL

Write a Comment

Comment