Your WordPress URL references your site on the web and the location of your site’s files and admin screens. There are certain conditions in which a user may want to change his or her WordPress URL.
It may be as a result of wanting to change from a domain to another sub-domain, updating from www to a non-www. It may also be a result of moving files around or migrating from HTTP:// to HTTPS://.
There are some possible ways a user can use to change his or her URL. This article is mainly to give guidelines on how to achieve the desired results.
A user who decides to change their WordPress URL can do so using the following methods
How to Change WordPress URL via Admin Dashboard.
This is the most common method to use in changing WordPress URLs. To do this click on “settings ” from the dashboard menu and then click on “General” to access the general setting screen.
Once on the screen, you are to update the WordPress address (URL) and your site’s address (URL). The WordPress address shows the address of your site while the site’s address shows the address of your WordPress core files.
You are to ensure that both addresses match together or else you want to assign a specific directory to WordPress.
Once you have clicked on “save changes”
It is important to note that the WordPress dashboard will now be accessible via the new WordPress URL.
If you have accidentally input a wrong address(URL) you can rectify the mistake by overriding the settings in the admin by editing the wp-config PHP file.
Changing WordPress URL via the wp-config.php file
This is the second most common method of changing WordPress URL. It is important to note that the values in your wp-config.php file override the settings on your WordPress admin screens.
The wp-config.php file is located in the root directory of your WordPress site and can be accessed via FTP, SSH, or WP-CLI. If the fields are not editable then it is likely because they are hard coded in the file.
To change your URL, simply add these two lines of shortcodes somewhere above the lines that tell you to stop editing. The shortcodes are:
define('WP _Home; 'http://yoursiteurl.com'); define('WP_SITEURL; 'http://yoursiteurl.com');
Save your wp-config file and close it. Once you log in to the general settings menu on the dashboard you will find out that these two fields (WordPress address and site address) have been graded out. You can only edit them by removing those two lines from your wp-config file.
Changing WordPress URL Directly In the Database
The method requires the use of “PHP My Admin” which is accessible from your cPanel. This method is seen as a last resort as it requires a high level of professionalism because If in the case you encounter a problem in doing so, it may break your site.
If you are not comfortable with this method you can contact your developer for help and make sure your site is backed up before commencing.
While on the PHP MyAdmin page, click on the database which is on the left-hand side of the screen. Then scroll down and click on the wp options table.
Then look out for the site URL and home field and double click to be able to edit it. Input the new URL for your WordPress site and your changes will be automatically saved.
Changing WordPress URL using WP-CLI
This is another method of changing URL. To make use of this method you will need SSH access to your site which is provided by certain WordPress Hosting Companies like Kinsta.
To do this, you have to input these command lines:
wp option update home 'http://yoursiteurl.com' wp option update siteurl 'http://yoursiteurl.com'
I hope that after reading and going thorugh this article, you were able to understand the topic and able to changer your WordPress URLs easily.
Since you were interested in this article, I figured you might be interested in this one too on How to Change Domain Name in WordPress, make sure to read it.
If you have any questions on how to change your wordpress urls, feel free to ask me in the comments section.