How to change a WordPress site URL
Configure WordPress to work with a different URL
Sometimes you may need to change the URL of your WordPress site.
For example, it is a common practice to develop the new version of your site in a subfolder and when it is ready to move it into your root directory.
WordPress, however, relies on its URL settings to work correctly.
This means that if you simply move your files and database it will not work properly.
The URL settings are located in the application database. Fortunately, direct database modification can be avoided by using a nice function provided by the WordPress developers named "update_option".
Simply add these lines to the functions.php file of your theme:
Then simply load your site from its new location - it should work just fine.
Note that after you run your site once and you make sure it works you should delete those lines from your functions.php file. The settings are already stored in your database and should not be modified each time your site is loaded.