You can change the domain name for your WordPress site any time you like, but there are a few important settings that must me made in order to make the switch.
Make sure to carefully follow the steps below to ensure it's done properly.
2 options to change the URL
The following are instructions for moving a WordPress installation from one URL to a different one. There are two different cases for moving a WordPress install, as shown below.
The first case is when a WordPress site moves from a sub-directory to its parent domain. For example:
If this option applies to your site, ignore the "Getting Started" section below and proceed to the 'Changing the base URL set in your WordPress settings' section.
The second case is when a WordPress site moves from one fully hosted domain to a different one. For example:
If this option applies to your site, begin with the 'Getting Started' section.
Since WordPress only works properly on a domain that is Fully Hosted, you must make sure that the new domain you wish to move your site to is Fully Hosted in the DreamHost panel. In the above example (Case 2), the site is moved from one domain to a completely new one.
Make sure that the new domain is:
- fully hosted at DreamHost, and
- fully hosted under the same FTP user as the old domain as it will make it easier when it comes to moving the WordPress files.
For more information on adding a hosting to a domain, see the Adding domains article.
Changing the base URL in your WordPress settings
WordPress relies heavily on a base URL in order to properly load your media, pages, and so on. Since you are moving the WordPress site to a different URL, you also must update the base URL set within your WordPress site's settings in order to reflect the URL changes.
- Log into your WordPress Dashboard.
- Navigate over to Settings > General.
- Locate the "WordPress Address (URL)" and "Site Address (URL)", and then write down the EXACT URL listed for "WordPress Address (URL)" which you will use later.
- Change the URL for both "WordPress Address (URL)" and "Site Address (URL)" to its new URL.
- Save your changes
- Log out of your WordPress dashboard and close your browser's window, but do not attempt to load the site just yet.
Changing the base URL using phpMyAdmin
If you cannot access the WordPress site through your user, you can instead use phpMyAdmin to update the URL.
Visit the following article for more information on how to log into phpMyAdmin:
- Open phpMyAdmin.
- Look for your wp_options table after selecting the appropriate database with which the WordPress installation is associated.
- Scroll to the wp_options row and select the first icon under the actions tab.
- When you scroll over these options, "browse" will appear.
The two options, the 'siteurl' and 'home', determine the WordPress URL and have the same affect as making the changes in the General Settings area of WordPress area; which if unavailable due to errors, is a good alternative.
- Select the pencil option to the left.
- Alter the URL by typing in a new one.
- Click the Go button to save the settings.
Moving the actual WordPress files
If you choose to use FTP for example, you can move the files and folders within the server as your user has access to both domains.
Correcting any broken paths
Before you proceed, you should back up your database since the following changes may cause issues. For more information on how to backup up your database, visit the following article:
- Once you've moved the WordPress site’s files to the new domain’s web directory, check to see if you are able to view the site.
- You may notice that the site appears broken, as if the CSS and media files are missing.
- They are not missing, but the URLs are incorrect (assuming you properly moved the new data over to the new domain’s directory).
- Update the hardcoded URLs which are defined in the database.
- Use the following WordPress plugin which can help you update the URL paths that are experiencing problems:
- If you are familiar with the command line, run the following command for the same effect (assuming you saved the old WordPress address):
[server]$ wp search-replace http://example.com http://new.example.com --dry-run
- The --dry-run call at the end tests the address
- If the changes make sense to you, then run the above command again without the 'dry-run' call.