WordPress Relocation Without Editing the Database

Here’s a tip I picked up on the WordPress hackers’ list: you can change the “siteurl” WordPress option simply by adding define('RELOCATE',true); to the wp-config.php file and browsing to wp-login.php.

The “siteurl” option—or what’s called “WordPress address” under the admin options menu—is a database value that refers to where the actual WordPress files live, as opposed to where the site appears to be, which is the “home” option (called “Blog address” in the options panel).

For example, if I have my site located at www.ilfilosofo.com, it would be easier to keep track of WordPress files, manage upgrades, etc., if I were to put all the files in a sub-directory, say www.ilfilosofo.com/wp. Everything would still appear at www.ilfilosofo.com (the “home” setting), but the files would actually be at www.ilfilosofo.com/wp (the “siteurl” setting). Normally you’d have to edit the database to do this, and it’s something I do a lot.

(Note that contra the hackers list, this resets only the “siteurl” option, not the “home” option.)

Since I’m frequently editing the database just to change the “siteurl” and “home” options, what I’d really like is to be able to set them in wp-config.php. Lead WP developer Matt Mullenweg has suggested something similar, so I submitted a patch with the hopes of getting this feature into a future version of WordPress.


  1. hi filosofo! great tip. can you help me in this case: i have a blog (with all contents, images, pages, posts) in domaindotcom/blog
    i want to change the url for this project to
    what is the correct and easiest way to do that? what more i need to do? i must uploads all the files to the new ‘site’ dir? sorry for my english.
    thanks a lot!

  2. hi filosofo. can you return me about this case above… thanks!

  3. what is the correct and easiest way to do that?

    It depends on whether in your posts you link to stuff in /blog/. If not, you can just add the WP_SITEURL and WP_HOME constants in your wp-config.php file.

    Otherwise, you might need to do a search and replace in the database itself or in the sql dump of your database.

Post a Comment

Your email is never shared. Required fields are marked *


One Trackback