Scroll To Top

This article explains how you can set or change your WordPress installation to use multiple domain names. I call this changing the site url in WordPress dynamically.

Dynamically set your Wordpress Siteurl and Home url

Add these lines to your wp-config.php file:

//Override the db site url
define( 'WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] );
define( 'WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);

Note: The above only works for http connections.

Change your site url

If you are not using a development server with a different domain name, you can change the live domain by adding this line of code to your wp-config.php file:


Then you can login to navigate to Settings > General and change your url.

Once you have changed the url you can delete or comment out the relocate line in wp-config.php