In this article we will discuss how to change the site URL in WordPress. Sometimes you may need to change the URL of your WordPress site. Maybe you are changing domains, moving to a subdomain to main domain, updating from www to non-www, migrate from HTTP to HTTPS.
For example, it is a common practice to develop the new version of your site in a sub folder (like example: https://www.thecodedeveloper.com/demo ) and when it is ready to move it into your root folder (https://www.thecodedeveloper.com). Whatever the reason may be, there are a few different methods you have when it comes to changing the URL.
There are two easy methods to change the site URL in WordPress 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 “https://www.thecodedeveloper.com” is the correct URL of your site.
Method 2: Edit functions.php
Simply add these below two code lines to the functions.php file of your theme.
update_option( 'siteurl', 'https://www.thecodedeveloper.com' ); update_option( 'home', 'https://www.thecodedeveloper.com' );
Use your own URL instead of https://www.thecodedeveloper.com
Then simply load your site from its new location (https://www.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.