If you want to change a WordPress site’s domain name (or base URL), which will often happen when you’re copying a site from staging to production, or from local to live, there are a number of steps to following, outlined at http://codex.wordpress.org/Moving_WordPress.
However, here is a shortened summary of how I run this on non-multisite sites (multisite sites are a pain!):
1. Copy the files to the new server (or folder on your local machine, if you’re making a local copy of a site)
2. Set up your database and permissions, and fill in the details in wp-config.php
3. Set up your domain name to point to the correct server (e.g. edit your vhosts file, if it’s a local copy).
4. Before trying to access wp-admin, you’ll need to change the site_url option. The simplest way I’ve found comes from the Moving_WordPress page:
a) Open up wp-login.php
b) Find this line:
require( dirname(__FILE__) . '/wp-load.php' );
and insert the following lines below:
//FIXME: do comment/remove these hack lines. (once the database is updated) update_option('siteurl', 'http://your.domain.name/the/path' ); update_option('home', 'http://your.domain.name/the/path' );
c) Go to yourdomain.com/wp-login.php (rather than directly to yourdomain.com/wp-admin/) and log in. This will update the options for you.
d) Remove the lines you added to wp-login.php
5. Now you should be able to have access to the WordPress admin dashboard, however you now need to update all the URLs that refer to the old domain name.
6. Download and install the great Search and Replace plugin.
7. Go to Tools -> Search and Replace, and do a search and replace (in the bottom section first) in all the tables it lists, of your old domain to your new domain name (don’t put the http:// bit on, makes sure it covers all). This will do a safe replace of all serialized WordPress data.
You should be ready to go. Occasionally you have to use the ‘drastic’ search and ‘replace all’ (at the top of the Search and Replace page) to pick up a few instances in tables that aren’t covered by the plugin, but this is less often.
Do you have a better way? Let me know in the comments below.