WordPress: how to change site URL

After installing and using WordPress, some references to the site address specified during the configuration (i.e.: are stored in the database.

If you need to change such address at a later time, you need to perform some steps to avoid references to the old address to persist in the DB.

Let’s see what to do, assuming that WordPress was initially configured for the address and that you are going to move it on

First thing to do is to perform a database backup, just in case you make mistakes during the procedure.

After we make sure we have such DB backup, we need to launch the following SQL queries on the database (obviously and must be replaced with the addresses you chose):

UPDATE wp_options SET option_value = replace(option_value, '', '') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, '','');
UPDATE wp_posts SET post_content = replace(post_content, '', '');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'','');

If after these operations you are no longer able to access website on the new URL address, you probably made some mistake in the first of the four queries. In that case use WordPress relocate di functions, that can be enabled by inserting the following line at the end of the wp-config.php file:

define('RELOCATE', true);

Save the file and open the address, then type in your username ad password, click on Settings->General and make sure that both the lines “WordPress Address (URL)” and “Site Address (URL)” contain as address.

Previous post

How to download Google Chrome offline installer

Next post

WordPress: how to change tables prefix

Fulvio Sicurezza

Fulvio Sicurezza

No Comment

Leave a reply

Your email address will not be published. Required fields are marked *