How do you change your WordPress site URLs? If you move the WordPress installation to another directory or transfer the instance to a new domain, the URL for WordPress must be changed.
This article will discuss the most common reasons to change the URL on WordPress sites, the difference between WordPress address vs. site address, and how to change WordPress site URLs with various methods.
The Most Common Reasons to Change the URL on WordPress sites
Although it is recommended to choose the URL of your WordPress site as long-term as possible, there may be times when you need to change it.
These are the most common reasons to change the URL of your WordPress sites:
- Moving a WordPress site from a local server or test environment to a live server.
- Admin areas will be accessible through a subdirectory in the future. This can be achieved by changing the URL of the WordPress site.
- If you are moving a WordPress domain, in this case, it is essential to set up redirects in WordPress for the old pages to be redirected to the new pages.
- The SSL certificate has been obtained, and the website has been converted to HTTPS. Once again, you should set up a redirect from the old HTTP site to the HTTPS site.
How to Change WordPress Site URL?
It is essential to know how to change the URL of your WordPress site regardless of whether you are switching from HTTP to HTTPS, changing the domain name, migrating from a local server to a live server, or moving to a subdomain.
As you will see in this section, there are several different methods you can utilize to change the URL of your WordPress site easily.
Method 1: Change WordPress Site URLs from Admin Area
As far as beginners are concerned, this is the most straightforward and user-friendly method if you have access to your WordPress admin panel.
Follow these steps to use this method:
- Go to Settings in your WordPress dashboard.
- Click the General.
- Change your WordPress site URLs in the WordPress Address and Site Address boxes.
These URLs are likely to be the same for most websites.
- Click the Save Changes button to save your URL changes.
It is now possible to check your website to ensure everything is functioning correctly.
Method 2: Change WordPress Site URLs Using functions.php File
You will need to use this method if you cannot access your WordPress admin panel.
Follow these steps to use this method:
- Access to your WordPress site using an FTP client.
- Locate your WordPress theme folder.
Typically, this would be in the following location: /wp-content/themes/your-theme-folder/.
- Open the functions.php file and edit it using your preferred text editor.
- Add the following code to the bottom of the file:
update_option( 'siteurl', 'https://example.com' ); update_option( 'home', 'https://example.com' );
- Replace ‘https://example.com’ with your site URLs.
- Save your changes and upload the file back to the server using FTP.
You can now visit your website to determine if everything is functioning as it should.
Using this method, you can update the databases with the new URLs of the sites. Whenever you load your functions.php file, WordPress updates the URLs in the database for your website.
If your site works correctly, you can remove the two lines of code from the functions.php file in your WordPress installation.
Method 3: Change WordPress Site URLs Using wp-config.php File
This method can be used if you need help locating your functions.php file or are unsure which WordPress theme you need to edit.
You will need to include the URLs of your website in the wp-config.php file in your WordPress installation. This file has several basic settings, which can be found in your website’s root folder.
Follow these steps to change the WordPress site URL with wp-config.php:
- Access to your website using an FTP client.
- Locate the wp-config.php file.
You will most likely find this file in your domain’s root folder.
- Open the file in the editor.
- Add the bellow code just above the line that says, ‘That’s all, stop editing! Happy publishing’:
define( 'WP_HOME', 'https://example.com' ); define( 'WP_SITEURL', 'https://example.com' );
https://example.comwith your domain name.
- Save your changes and upload them back to your server.
After that, check your website to ensure that everything is functioning as it should.
Method 4: Change WordPress Site URLs in the Database Using phpMyAdmin
Changing the URLs directly within your WordPress database is another method of updating WordPress site URLs. Your WordPress hosting account dashboard provides you with direct access to this feature.
Follow these steps to change the site URL in the WordPress database:
- Log in to your web hosting account dashboard.
- Click on the phpMyAdmin icon in the Databases section.
Note: According to your hosting provider, the steps may differ slightly. However, all cPanel hosting providers will allow you to change the WordPress URL in cPanel.
By clicking on this button, you will be automatically launched into phpMyAdmin. This web-based application provides you with a convenient way to edit MySQL databases.
Follow these steps to use it:
- Click on your WordPress database in the left-hand column.
You will be able to view tables contained within your WordPress database by using this method.
- Click on the wp_options option.
As a default, the database prefix on the WordPress database is wp_. However, since you can change the WordPress database prefix, it could be something else.
Now, you will see rows within the options table that includes WordPress homeurl and siteurl.
- Locate the option_name column where siteurl and home will be listed.
- Click on the pencil Edit icon to the left of each row.
- Change the option_value field to your new site URL.
It may be necessary to scroll down the options table to locate the name of the home option.
- Click on the Go button in the bottom right corner to save your database changes.
Then, you can check your website to ensure everything is functioning correctly.
Method 5: Change WordPress URL With WP-CLI
If you would like to edit the URL of your site using the WordPress Command Line Interface (WP-CLI), you can do so using this method.
To use this method, you will need to have access to your site via SSH and be familiar with how to access your site via WP-CLI.
Follow these steps to use this method:
- SSH access to your site using WP-CLI.
- Edit the following two commands to edit your site’s URL:
wp option update home 'http://yoursiteurl.com' wp option update siteurl 'http://yoursiteurl.com'
What’s the Difference Between WordPress Address vs. Site Address?
If you wish to change the WordPress URL, you will need to update two separate settings: the WordPress Address and the Site Address.
For many beginners, this can be confusing as they need help understanding the differences between the two settings.
WordPress Address (URL) is a web address where your WordPress files and folders are stored, including your administrator pages, media files, plugins, themes, etc.
In WordPress, your Site Address (URL) serves as your website’s public-facing interface. The address of your website is what visitors will enter into their web browser to access it.
There is no difference between the WordPress Address and the Site Address URL for most users. The majority of large companies host their WordPress sites on separate servers.
This is because they have many applications on their corporate website and wish to isolate where these applications are hosted to improve WordPress security. In most cases, these two WordPress URLs will remain the same.
Frequently Asked Questions
In this section, we will answer some frequently asked questions to help you find your solution.
When you cannot edit the WordPress address (URL) in the settings page of the admin area, it means the URLs have been hardcoded in the wp-config.php file.
Suppose you want to change your WordPress URL. In that case, you can follow any of the methods above to modify the wp-config.php file and make the necessary changes.
Nontechnical users can accidentally change the WordPress URL and Site Address settings from the WordPress administration area when using WordPress.
After that, you’ll have to follow the methods above to change the WordPress URLs via functions.php and wp-config.php or modify the database.
Our discussion in this article pertained to the most common reasons for changing the URL of a WordPress site, the difference between a WordPress address and a site address, and various methods of changing a WordPress site URL.
It is of great interest to us that you take the time to read this article, and we are grateful for your time.