SITUATION:
You’ve had a WordPress site since a while and want to change its URL by which it is called. WordPress needs to have a constant URL to be able to work. If you just configure the web server to use another URL, it won’t work. The original URL stored in your WordPress database, which you gave in WordPress installation interface, will still be used by WordPress to create some redirects and your site won’t work at all.

SOLUTION:
1. – (SPAGETTI) Create a new web server vhost (with your new URL) which will proxy all requests sent to it directly to the old one. Well, this is one way to do it which is not elegant at all and can create some nasty problems when using redirects. But still feasible.

2. – (BEST) Change the name of the WordPress URL in its configuration file. The configuration file, called wp-config.php, is located in the root directory of your htdocs. Just add the following 2 lines at the end of the file which will override the settings in the WordPress database:
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');