There are times when you need to move WordPress around within your server, and times when you need to move WordPress from one server to another. You don’t need to reinstall. WordPress is flexible enough to handle all of these situations.
When Your Domain Name and URLs Do Not Change
Moving your domain without changing the Home and Site URLs of your WordPress site is very simple, and in most cases can be done by moving the files.
- If database and URL remains the same, you can move by just copying your files and database.
- If database name or user changes, edit wp-config.php to have the correct values.
- If you want to test before you switch, you must temporarily change “siteurl” and “home” in the database table “wp_options” (through phpMyAdmin or similar).
If you had any kind of rewrites (permalinks) setup you must disable .htaccess and reconfigure permalinks when it goes live.
If you are changing to a new server but same domain, all you need to do is edit wp-config.php with your new database/user information and upload everything as it is to your new server.
When Your Domain Name or URLs Change
When your domain name or URLs change – i.e. from http://example.com/blog to http://example.com, or http://example.com to http://example.net – there are additional concerns. The files and database can be moved, however references to the old domain name or location will remain in the database, and that can cause issues with links or theme display.
If you do a search and replace on your entire database to change the URLs, you can cause issues with data serialization, due to the fact that some themes and widgets store values with the length of your URL marked. When this changes, things break. To avoid that serialization issue, you have two options:
- Only perform a search and replace on the wp_posts table.
- Use the Search and Replace for WordPress Databases Script to safely change all instances. ( If you are a developer, use this option. It is a one step process as opposed to the 15-step procedure below )