There can be many reasons for changing your WordPress url. It can be to move from http to https or moving to another domain or a subdomain. In this article we will cover different methods you can use to change your url in WordPress.
Table of Contents
Change URL using the admin dashboard
Visit Settings -> General. You will find two text fields here –
- WordPress Address (URL)
- Site Address (URL)
The WordPress Address is the url to your core WordPress files such as media, admin pages, plugins and themes. Whereas the Site Address is the public url to your website that the visitors can visit to view your website.
You can update both the fields, both should match unless you are storing your WordPress files on a different server.
Change URL from the wp-config.php file
If for some reason you are unable to access your admin dashboard then this method is best to change the url in WordPress. Settings in the wp-config file will override the settings from the admin dashboard. You can use FTP to connect to your server and find the wp-config file in the root directory of your WordPress files.
Add the below lines of code to the wp-config file
define( ‘WP_HOME’, ‘http://newurl.com’ );
define( ‘WP_SITEURL’, ‘http://newurl.com’ );
After adding the above lines, save the file and close it.
If you visit Settings -> General from your admin dashboard then you will find that the WordPress Address (URL) and Site Address (URL) text fields are grayed out now. You can’t edit them.
If you want the ability to edit from your admin area then you will need to remove the code from the wp-config file that we inserted earlier.
Change URL using the Database
It is best to take a backup of your database before making any changes directly to it. We will use the phpMyAdmin tool for accessing the database.
Steps to change the url from database:
- Open phpMyAdmin.
- Select your database from the left sidebar and choose the wp_options table. The wp in the table name can be different so choose accordingly.
- Find the siteurl and home fields in the option_name column and edit the values in the option_value column respectively.
Conclusion
The above methods should help you change your url in WordPress. You can use the method you are most comfortable with. Remember to take a backup of the database before making any changes to it.