My name is Svetoslav Marinov, which has short forms such as Slavi and Svetlio. I am originally from Bulgaria, Europe. Currently, I live in Ontario, Canada and I am working as a Web Developer. With my blog I want to share my knowledge and exchange ideas. Svetoslav is a DZone MVB and is not an employee of DZone and has posted 12 posts at DZone. You can read more from them at their website. View Full User Profile

How to Change The Site URL of a Wordpress installation

  • submit to reddit
When you install Wordpress it saves the current address in the db keeps using it.  If you install it on production and start using Wordpress then you'll be fine.  How I use wordpress is I first install it on my machine, setup plugins, themes etc.  When the site looks alright I move it live server.

I also make sure that the db name, user and password are the same on development and production server.  Here is what I use to make the installation work i.e. Wordpress ignors the site url saved in the db.

Add these lines in config.php to make the installation work on dev and on production

define('WP_HOME','http://' . $_SERVER['HTTP_HOST']);
define('WP_SITEURL','http://' . $_SERVER['HTTP_HOST']);
Published at DZone with permission of Svetoslav Marinov, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)



Nitin Reddy replied on Sun, 2011/05/15 - 5:02am

An alternative means of setting the home and the site url is to modify the values in the wp_options table in the database. The solution you have posted is actually a 'cleaner' way of doing it because it switches the home and site url host name based on the call from a browser rather than hard-coding it in, so moving the install to a different server is (at least in theory) as simple as copying the database and files across.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.