Thursday, May 26, 2016

How to Change a WordPress site URL or Directory



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 rdy to move it into your root directory.

WordPress, however, relies on its URL settings to work correctly.

This mns that if you simply move your files and database it will not work properly.

The URL settings are loed in the appliion database. Fortunately, direct database modifiion can be avoided by using a nice function provided by the WordPress developers named "update_option".

Simply add these lines to the functions.p file of your theme:

update_option('siteurl','http://www.new-site-address.com');
update_option('home','http://www.new-site-address.com');
Then simply load your site from its new loion - 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.p file. The settings are alrdy stored in your database and should not be modified ch time your site is loaded.

No comments:

Post a Comment