How to Move WordPress to a New Server

If you are a WordPress developer you will need to move wordpress between servers. You may need to launch from development to live, or just help change hosts or domain names. There are many detailed tutorials to help you move. I want to review some best practices you can implement while the site is in development to help make a move easier as well as some tips for after you move.

Use Relative Links

I’m going to go back to basics here for a minute to try to make this easy for anyone to understand. When you make a link you can build the path in a relative or absolute fashion.

Relative links do not begin with http://. They define a path relative to where the code is executing.

When you manually create links to your own site from within the wordpress editor you should use a relative link. Here’s an example of a relative link to an image in a typical theme directory.


The leading slash tells the browser to begin in the web root and then look for wp-content and so on. Now, if you move to a new domain you don’t have anything to update.

Use WordPress Template Tags

Any links you create within your theme files should use WordPress template tags. These will output the domain name and path to wordpress automatically.

Here is an example of a link to a javascript file using template tags.

<?php echo get_stylesheet_directory_uri(); ?>/js/myjsfile.js

This would output:


Update Domain after Move

After you move WordPress to a new domain or location ie a subdirectory) you will not be able to load the admin until the domain is updated in the database. You need to update two places in the wp_options table.

mysql update wp_options set option_value='' where option_name='home';
mysql update wp_options set option_value='' where option_name='siteurl';

Update Links after a Move

Sometimes you just have to update different links after you move a site. If so, you can try a plugin which will update all of the links in the content (not templates) for you. I’ve had a good experience with Velvet Blues Update URLs

Just make sure you match the old and new URLs carefully. If you put a slash on the end of the old URL it should also be on the end of the new URL.

Good luck with your move!