It is possible to change the domain name for your WordPress site at any time you want to but you need to know some key setting prior to switching.
Ensure that you carefully follow the below steps to change the settings properly.
Why should you change the URL?
In order to move a WordPress installation from one URL to a different one there are different cases:
Case #1 —Moving from a subdirectory
In this case, a WordPress site moves from a sub-directory to its parent domain. For example:
- It moves from http://example.com/blog
In case you have already moved your domain to a new URL, you won’t be able to log in as WordPress is configured to use the old URL.
Case #2 — Adding or removing www
The next reason to update your URLs is when you need to add or remove www from your domain. If previously it was example.com, you might want to change it to www.example.com.
When you change the URL, you might see a browser redirect error when after browsing your site. It might display the message as “Too many redirects” or “The page isn’t redirecting properly”.
Case #3 — Adding ‘https’ to the URL
In case you’re using an SSL certificate, the first part of the URL will change from ‘http’ to ‘https’. In case you’ve already made this change, you won’t be able to log in as WordPress is configured to use the old URL.
Case #4 — Moving to a new domain
Lastly, when a WordPress site moves from one fully hosted domain to a different one, you need to change the URL.
- Move from http://example.com
Different Ways to Change the WordPress URL
Note: Check the below two options that explain the ways to change your HOME and SITE URL for immediately getting the access to your WordPress site and dashboard.
After you log in, to update all the URLs in your database to the new URLs, you will need to use a plugin. Check the below article for complete instructions:
Option 1 – Change the HOME and SITE URL using phpMyAdmin
If you have made any of the changes above, you won’t be able to log in to your dashboard. Instead of that, use the phpMyAdmin to update the HOME and SITE URLs.
1. Open phpMyAdmin.
2. In the left pane, click your database. You will see a list of several tables below it. Click on your wp_options table.
3. Find the ‘siteurl’ and ‘home’ rows. In order to edit, click the pencil icon next to each.
4. You will see “browse” when you scroll over these options.
Again to edit, click on the pencil icon next to each.
5. Type a new URL for altering the previous one.
6. To save the settings, click the Go button. This needs to be done for both the ‘siteurl’ and ‘home’ options.
After this is completed, you will be able to log into your site at example.com/wp-login.php.
Though you get an access to your site, there might be some former URLs in your database which will still use the old URL. Now you will need to use a plugin to update all URLs in your database to the new URL.
Option 2 – Changing the URLs in your wp-config.php file
It is possible to change the URLs in your wp-config.php file. This is a bit easier as compared to editing your database and gives you quick access to your site.
Note: In the following steps, it is assumed that your Home and Site URL should be ‘example.com’.
Use FTP or SSH to log in to your site.
Go to the WordPress directory and edit the file named ‘wp-config.php’.
Now, add the following lines in that file just above /* That’s all, stop editing! Happy blogging. */.
When you visit the site now, check if you can log in.
You will get immediate access to your site but the database won’t be configured to use the correct HOME and SITE URL. It is important to use a plugin to update all URLs in your database to the new URL.
Verifying the New HOME and SITE URL
In case you have used the first option from above, the HOME and SITE URLs must have been updated in the database. You can verify that your site is now using the correct URLs in your dashboard.
1. Log in to your WordPress Dashboard.
2. Go to Settings > General.
3. Here you will be able to view the HOME and SITE URL your WordPress site is configured to use.
Note: In case you have used the second option, the database won’t update your HOME and SITE URL. Go to the Settings > General page where all the entries are grayed out with the values that you entered in your wp-config.php file:
To update all URLs in your database to the new URL, you should use a plugin.
After updating, remove the lines from your wp-config.php file. Recheck the Settings > General page and check that those fields aren’t seen grayed out.
This is the way you can change the WordPress site URL.