If needed, you may wish to change the domain name for your WordPress site.
You can use the following steps to ensure it's done properly, as there are a few important settings that must me made in order to make the switch.
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 shows a WP site move from a sub-directory to its parent domain. The second case shows a WP site move from one fully hosted domain to a different one.
- Case 1: Moving from a sub-directory to a parent domain or vice versa. An example of this is to move from http://example.com/blog to http://example.com
- Case 2: Moving from one domain to a completely different domain name. An example of this is to move from http://example.com to http://dreamhost.com
If the domain will remain the same and the first case more closely matches what you wish to accomplish, then you can ignore the "Getting Started" section below and proceed to the Changing the base URL set in your WordPress settings section. If the second case more closely matches what you wish to accomplish, then 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 system. 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 set 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 WP 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
You can use FTP, SFTP, or SSH to move your WordPress files. As mentioned previously, keeping the old domain and the new domain on the same user simplifies this process.
If you choose to use FTP or SFTP 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.