Change The Site URL in WordPress

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 sub folder (like example: thecodedeveloper.com/demo ) and When it is ready to move it into your root folder (thecodedeveloper.com).

There are two easy methods to change the Site URL manually.

Method 1: Edit wp-config.php

It is possible to set the site URL manually in the wp-config.php file.  Add these two lines to your wp-config.php, where “thecodedeveloper.com” is the correct URL of your site.

define('WP_HOME','http://thecodedeveloper.com');
define('WP_SITEURL','http://thecodedeveloper.com');
Method 2: Edit functions.php

Simply add these below two code lines to the functions.php file of your theme.

update_option( 'siteurl', 'http://thecodedeveloper.com' );
update_option( 'home', 'http://thecodedeveloper.com' );

Use your own URL instead of http://thecodedeveloper.com.

Then simply load your site from its new location (http://thecodedeveloper.com) – it should work just fine. Note that after you run your site once and you make sure it works you should remove those lines from your functions.php file.

Leave a reply
Captcha Click on image to update the captcha .