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:

define('RELOCATE',true);

Then you can login to YourDomain.com/wp-login.php 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