Move your WordPress blog to a new domain in 10 steps!

A friend recently asked me how to move his blog, which is on /blog/ on his domain, to a new domain on it's own. The steps are easy, but have to be taken in the right order to make sure you're not annoying your users and the search engines:

  1. Put up a robots.txt on the new domain with the following contents:
    User-agent: *
    Disallow: /
  2. Copy the database and files to the new domain.
  3. Edit wp-config.php to have the right database settings, and add the following lines, replacing sample.com with the right domain:
    define('WP_SITEURL', 'http://www.sample.com/');
    define('WP_HOME', 'http://www.sample.com/');
  4. Now set up your blog install, with the same settings as on the old domain (if you have a caching plugin installed, delete your cache files).
  5. Install the Search and Replace plugin, and do a search and replace for your old URL's and change them with your new URL's.
  6. Once you're done, and you've checked everything works twice:
  7. Remove the robots.txt file.
  8. On your old blog, add the following line to your apache .htaccess or vhost-config:
    Redirect 301 /blog/ http://www.newdomain.com/
  9. Remove the old blog code and database.
  10. Change your FeedBurner account, if you have one, to pick up the correct feed.

That should be it. If you have any suggestions or spot things that I've missed, please note them in the comments!

Related posts

  1. Changing your permalink structure
  2. Simple scripts for speedy WordPress actions
  3. 11 Top WordPress Plugins Every Blog Should Have
  4. Speed up and clean up your WordPress!
  5. Make WordPress' search function suck Less.

Want more WordPress tips?

You should subscribe to my WordPress Newsletter, as you'll get a whole lot more WordPress tips and tricks there! Also, subscribe to this blog right now with RSS, or daily or weekly emails!

64 Comments to “Move your WordPress blog to a new domain in 10 steps!”

  1. Jonathan

    Jonathan Feb 15th, 2008 at 00:50

    Cool, i'll need to use it in the future =)

    but, what's the seo impact in this process? i mean will the 301 redirection make the search engines identify my new site as my old one?

  2. JLH

    JLH Feb 15th, 2008 at 06:15

    I liked the look of that search and replace plugin but for the life of me I cannot get it to display in english, being wordpress defaults to english I've never had to convert anything, oh well.

  3. Joost de Valk

    Joost de Valk Feb 15th, 2008 at 08:51 Delicious Digg StumbleUpon Twitter

    @Jonathan: yes this will take care of the SEO impact. You might see a slight dip in your traffic at first, but it should be pretty good after a month or so.

    @JLH: Hmm I haven't tried it out, I'll install it and see if I can get it working.

  4. Frank

    Frank Feb 15th, 2008 at 10:01

    Do you have upload the .mo-File for display in english?

  5. oeroek

    oeroek Feb 15th, 2008 at 10:48

    Very nice tutorial. Expecially the plugin that helps you replace the internal links in your posts. I have however one comment and one question with respect to this process.

    1) I think one step should be added in which you inform your visitors of the change. Your regular readers may be easier to reach but what about random reader who see a redirect and do not know why? Solutions could be to make sure not to change your design at the same time. Secondly I would add a message at the new domain that is shown only to people that originate from the old address stating that the blog has moved. This could also be done on the old blog but would probably kill the effect of the 301 redirect.

    2) Would it be possible to change the structure of the permalink at the same time. For example if your blog uses the month and date in the url and you would like to change that into the postname only. Moving to another domain name, or from /blog/ to the root would be a perfect time to make the change. Not sure if the search and replace plugin would be able to remove the month and date. Secondly, the htaccess should than be changed.

    What is your thought on the second item.

  6. Sylvain

    Sylvain Feb 15th, 2008 at 10:54

    It would be nice to do the same type of easy steps for ppl willing to migrate from wordpress.com to a self hosted wordpress domain name.

  7. Joost de Valk

    Joost de Valk Feb 15th, 2008 at 11:31 Delicious Digg StumbleUpon Twitter

    @Frank: ah is that the problem? :) (note to everyone else: Frank is one of the plugin's authors)

    @Oeroek: you can quite easily remove the date out of your URL: changing your permalink structure.

    @Sylvain: true, but I've got no experience with that :)

  8. Adam

    Adam Feb 15th, 2008 at 13:44

    May I know why I have to remove robots.txt file while moving wordpress blog to new domain?

  9. Joost de Valk

    Joost de Valk Feb 15th, 2008 at 13:45 Delicious Digg StumbleUpon Twitter

    @Adam: Just delete it, or remove the Disallow line.

  10. oeroek

    oeroek Feb 15th, 2008 at 15:17

    @Joost,
    thx a lot. It seems a lot easier than I thought. Implementing this on my blog was quicker than writing my post above.

  11. James Mann

    James Mann Feb 15th, 2008 at 16:26

    It seems pretty straight-forward and I wish I had this post to follow when I tried to move my gardening site from a bad hosting service to HostGator.

    I tried to move it along with the database but it just won't work so I asked HostGator to do it for me figuring I did something wrong, but they could not move it and make it work either.

    Looking back it may have been the wp-config

    Well I have been moving and redirecting each post from the old site to the new domain I purchased for it. Now I have two gardening sites on the go until I get all the old posts moved.

  12. JLH

    JLH Feb 15th, 2008 at 16:33

    @frank I've uploaded all the files, mo's included, but it still defaults to German. I tried modifiying the default language, since by default there is none, moved the mo file to /languages/ etc, to no avail.

  13. Joost de Valk

    Joost de Valk Feb 15th, 2008 at 16:34 Delicious Digg StumbleUpon Twitter

    @Frank & JLH: haven't had time to test it yet...

    @Frank: if you need help, let me know!

  14. Stephen Rider

    Stephen Rider Feb 15th, 2008 at 18:31

    Shouldn't Step 8 begin with "On your old blog..." ?

  15. rxbbx

    rxbbx Feb 15th, 2008 at 19:11

    Offtopic: Best wishes.. haha.. got an update via plaxo.

  16. Joost de Valk

    Joost de Valk Feb 15th, 2008 at 19:41 Delicious Digg StumbleUpon Twitter

    @stephen: yes indeed!

    @rxbbx: heh, thanks! It's tomorrow though :-)

  17. Joost de Valk

    Joost de Valk Feb 15th, 2008 at 22:02 Delicious Digg StumbleUpon Twitter

    @stephen: updated.

  18. Cody

    Cody Feb 15th, 2008 at 23:05

    Should this process work for moving from one host to another without changing the domain name? I've been trying to make that work for a few months now and can't get it.

  19. Joost de Valk

    Joost de Valk Feb 15th, 2008 at 23:07 Delicious Digg StumbleUpon Twitter

    @Cody: yes I think so... You can leave out some of the steps of course, like the search & replace and the 301 redirect.

  20. SEOidiot

  21. Henri

    Henri Feb 16th, 2008 at 17:38

    Joost, I think this must be the basic knowledge of every webdesigner :)

  22. Joost de Valk

    Joost de Valk Feb 16th, 2008 at 17:41 Delicious Digg StumbleUpon Twitter

    @Henri: well... that goes for about 90% of SEO in my opinion :)

  23. The Webmaster Forum

    The Webmaster Forum Feb 16th, 2008 at 22:16

    Sounds easy enough. Good to know if you "accidentally" choose the wrong name.

  24. Jimmy Daniels

    Jimmy Daniels Feb 19th, 2008 at 04:42

    If you use the following code in your htaccess, it will redirect all pages to the proper spot in the new domain. As an example oldsite.com/post-about-SEO/ would redirect to newsite.com/post-about-SEO/

    RewriteEngine On

    RewriteCond %{HTTP_HOST} ^.*oldsite\.com$ [NC]
    RewriteRule ^(.*)$ http://newsite.com/1 [R=301,L]

  25. Jimmy Daniels

    Jimmy Daniels Feb 19th, 2008 at 04:47

    Oh, as as for the wordpress.com blogs, if you paid to use your own domain name, all you have to do is get your blog working on your own hosting or server and then changes the dns, all of the yoursite.wordpress.com stuff will redirect to yoursite.com just as it would've on their site. I still get hits from google images and some of the wordpress tags pages since I moved the blog to my own server.

  26. Joost de Valk

    Joost de Valk Feb 19th, 2008 at 07:05 Delicious Digg StumbleUpon Twitter

    @jimmy: the simple one line 301 redirect I gave does exactly the same as your rewrite lines ;)

  27. Roger Wilkanson

    Roger Wilkanson Feb 19th, 2008 at 08:22

    One bit about the Feedburner feed.

    I subscribe to a couple of blogs (James Brausch and Aaron Brandon are good examples) that use the feed to run an email announcement list via AWeber. Bonus is that FeedBurner counts the AWeber subscribers are feed readers. Downside is that doing something like you describe in updating the Feedburner URL has caused the email list to receive a whole bunch of emails for posts that had already been made.

  28. Joost de Valk

    Joost de Valk Feb 19th, 2008 at 09:28 Delicious Digg StumbleUpon Twitter

    Good point Roger, I use aweber too, so I'll keep it in mind!

  29. Frank

    Frank Feb 19th, 2008 at 09:34

    @JLH: What is the language-constant in wp-config.php?
    define ('WPLANG', 'de_DE');
    The Plugin is default in german, yes. When the WPLANG '' is, then use WordPress automaticly the en_US languages-files.

    Please upload the mo-file and php-files include the folder searchandreplace.

    With best regards and sorry for my bad english.
    Frank

  30. Marc

    Marc Feb 19th, 2008 at 15:42

    Dude, I was in the midst of mapping out this process for a few sites.

    And you just saved me several hours of development time!!

    Thanks, this was perfect timing!

  31. Joost de Valk

    Joost de Valk Feb 19th, 2008 at 15:49 Delicious Digg StumbleUpon Twitter

    @Frank: thx for delivering such great service to my readers!

    @Marc: at your service :)

  32. Frank

    Frank Feb 19th, 2008 at 17:09

    @Joost de Valk: I'm a reader od your blog! Thx.

  33. Mike

    Mike Feb 21st, 2008 at 12:04

    Cheers for the heads up. I was thinking that the redirect may need a little bit of hacking to ensure that all pages redirect to their new locations rather than everything going back to the blog homepage - just to make sure that Google passes over any link love you've developed to earlier posts. I'm probably over thinking the whole thing.

  34. colbert

    colbert Feb 28th, 2008 at 10:30

    Thanks to your post, my migration project was successful. Thanks again. The blog broke earlier as I cancelled the sql import half way but it works now....Great tips again

  35. Jomar

    Jomar Mar 4th, 2008 at 15:50

    Hi Joost!

    How many lines of 301 redirect a .htaccess accept?

    Would like to change all permalinks:

    /%year%/%monthnum%/%day%/%postname%/

    To:

    /%category%/

    How can I set the .htaccess?

  36. Tristan de Montebello

    Tristan de Montebello Mar 8th, 2008 at 03:45

    Hi Joost,

    Love your blog. It has been VERY useful to me in the pas few months..

    I have a question.
    I recently moved my clients blog from domain.tld/blog to domain.tld

    I obviously redirected everything.
    I also blocked all /blog in my robots.txt

    Was that necessary? Is the redirect enough for google and Co?

    What's better for SEO?

    Thankx in advance, keep up the good work.

  37. Joost de Valk

    Joost de Valk Mar 8th, 2008 at 09:48 Delicious Digg StumbleUpon Twitter

    @Jomar: you can do so with one RedirectMatch, as I explained over e-mail

    @Tristan: unblock it, fast. Google needs to be able to crawl /blog/ to find the 301 redirects. If you've done that, you should be ok.

  38. gofree

    gofree Mar 11th, 2008 at 08:19

    I got this when:

    Warning: Cannot modify header information - headers already sent by (output started at /home/ttc/public_html/wp-config.php:50) in /home/ttc/public_html/wp-includes/pluggable.php on line 390

    I installed a new wordpress, then drop all the table, next import sql database into it; followed your tips. Did I miss sth?

  39. Joost de Valk

    Joost de Valk Mar 11th, 2008 at 08:22 Delicious Digg StumbleUpon Twitter

    @gofree: what where you doing when you got this error?

  40. gofree

    gofree Mar 11th, 2008 at 09:49

    I installed my new blog using Fantastico, then I put robot.txt in, changed config.php using your tips, and pointing to a new database that I imported from my old blog. The result is that error???

  41. gofree

    gofree Mar 11th, 2008 at 10:43

    Now done, dude!!!
    It is the problem of .htaccess and
    define('WP_SITEURL', 'http://www.sample.com/ ');
    define('WP_HOME', 'http://www.sample.com/ ');

    As seen I left a space before ' this brought me the problem!

    Thx you very much for taking care.

  42. gofree

    gofree Mar 11th, 2008 at 10:50

    No man!!! I still got error when attempt to log in:

    Warning: Cannot modify header information - headers already sent by (output started at /home/ttc/public_html/wp-config.php:50) in /home/ttc/public_html/wp-login.php on line 12

    Warning: Cannot modify header information - headers already sent by (output started at /home/ttc/public_html/wp-config.php:50) in /home/ttc/public_html/wp-login.php on line 24

    Any help, plz.

  43. Joost de Valk

    Joost de Valk Mar 11th, 2008 at 10:52 Delicious Digg StumbleUpon Twitter

    I still don't know what you're trying to do... Email me on joost at this domain and we'll work it out.

  44. gofree

    gofree Mar 11th, 2008 at 11:39

    now sending email to you...

  45. Caleb

    Caleb Mar 13th, 2008 at 01:16

    very good tips. using it to transfer my blogger posts into the new site. thank you!

  46. Roel

    Roel Mar 17th, 2008 at 11:02

    Joost,

    After changing the wp-config.php file I get the following message: "You appear to have already installed WordPress. To reinstall please clear your old database tables first."

    There is another wordpress site running, but it's using a different database. The wp-config file is pointing to the proper (i.e. new) database so I'm not quite sure what's wrong.

    Any idea what I should change?

  47. Roel

    Roel Mar 17th, 2008 at 12:08

    Fixed: logging in to the control panel caused a database upgrade and now it works (well I now have some strange characters in old posts...)

  48. Roel

    Roel Mar 17th, 2008 at 19:52

    Joost,

    I think step 3 should be:
    define('WP_SITEURL', 'http://www.sample.com');
    define('WP_HOME', 'http://www.sample.com');

    so /without/ the trailing forward slashes.

  49. Jomar

    Jomar Mar 20th, 2008 at 19:10

    Hi Joost,

    It is safe make redirection to change the permalink structure using John Godley Redirect Plugin?

    I'm plannig change:

    /%year%/%monthnum%/%day%/%postname%/

    to:

    /%category%/%postname%/

    I have 173 links to change. This plugin can make a good job? Any problem with Google?

  50. Joe

    Joe Apr 28th, 2008 at 21:31

    How does this affect incoming links? Of course the page will redirect to the correct one but will the search engines still count it as an inbound link for the new site/address?

  51. Charles

    Charles May 2nd, 2008 at 14:42

    Very nice tutorial. I spend hours to find the solution and you make it looks easy to do.

    http://www.tldsco.com

  52. Venu

    Venu May 4th, 2008 at 09:04

    Joost,
    My WP was in a "blog" subdomain and wanted to move to the root domain.
    In wordpress, there is a easy of just setting the Blog address and it worked fine for me
    http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory

    Now for Google Bot, I need to redirect all the /blog URL's to root URL's

    The single line redirect that you have mentioned worked like a charm (I wasn't able to grasp the regex solutions mentioned in various other forums)

    But the problem is that now I am not able to access the wordpress admin page

    If i do venukb.com/blog/wp-admin, I get a 404 because of the redirect, how to avoid this ?

  53. Erno Hannink

    Erno Hannink May 20th, 2008 at 19:06

    Hey Joost, just used the 10 steps today to move my WP blog. Took a little bit more than 5 minutes but all went smoothly.
    Only due to the trailing / in step 3 I got a double // after the URL.
    And step 2 looks fairly easy here but I had to look up the details on other sites.
    Oh, and the search and replace plugin works nice.

    Thanks.

  54. roshan

    roshan Jun 13th, 2008 at 04:46

    thanks it really helped moving my domain! Great tutorial!

  55. Jennifer @ Quiverfull Family

    Jennifer @ Quiverfull Family Aug 11th, 2008 at 03:04

    Awesome. Used this along with the Moving Wordpress instructions at Wordpress, and it went very well. Thanks so much for the instructions, that 301 is awesome!

  56. Jill

    Jill Aug 11th, 2008 at 21:10

    Excellent. Good resource here. Moving a domain name is a tricky thing. You don't want to lose all your hard work promoting it. So follow these steps.

  57. Cbb

    Cbb Sep 23rd, 2008 at 22:59

    Thanx joost. Got here exactly what i was looking for.

  58. Velvet Blues

    Velvet Blues Oct 4th, 2008 at 19:48

    Our plugin is a bit more straightforward and just for site moves.
    With one click of a button, it can update permalinks as well as deep links in content.

    Check it out at: http://www.velvetblues.com/web-development-blog/wordpress-plugin-update-urls/

  59. Haplo

    Haplo Oct 18th, 2008 at 06:08

    Terrific guide! Unfortunately for me, the Velvet Blues easy plugin didn't worked on my blog :( So I used search and replace and it was a breeze.

    A question: does that line in the .htaccess also tells search engines that the page has moved permanently to the new address, so they can update their indexes, and so you will lose as little traffic and ranking as possible? (I'm not talking page rank, but when you do a search in google for something and your blog comes on the top spots)?

    Thank you!

  60. Peter Jones

    Peter Jones Oct 18th, 2008 at 13:40

    Thanks for your excellent tutorial. I need to replace my sub domain after few days. The single line redirect that you have mentioned will definitely work like a charm. Hope your tutorial will help me a lot to do this.

  61. Richard Kenedy

    Richard Kenedy Oct 18th, 2008 at 13:49

    I really appreciate your efforts to guide us with such a tutorial. But if I do it in this way will I not lost traffic of my website?

  62. Alberto Jones

    Alberto Jones Oct 18th, 2008 at 13:54

    Ok, nice tutorial. Can you say one thing? Is this the best procedure for SEO to maintain my page rank? Or you can describe some better procedure? Anyway, nice job. Thanks.

  63. houroc

    houroc Oct 22nd, 2008 at 22:21

    Help!!!!

    I used step 8,
    Redirect 301 / http://www.newdomain.com/

    to redirect everything but I keep getting this redirect loop error in firefox and in IE it just doesn't load up at all. Please help!!

  64. houroc

    houroc Oct 22nd, 2008 at 23:02

    Ok it's resolved now. My hosting company took care of it. If anyone else runs into this problem, here the code to fix it.

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule (.*) http://www.newsite.com/1 [R=301,L]

    You have to take everything out of your original htaccess and just add that.

Leave a Reply

Joost de Valk a.k.a. Yoast Want an avatar too?
Go to gravatar.com and upload your preferred avatar.

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="">

13 Trackbacks and Pingbacks

  1. Bookmarking the web - w07/2008
  2. Transférer votre blog WordPress vers un nouveau domaine en 10 étapes
  3. links | drainedge link fix
  4. WordPress Wednesday News: WordPress 2.5 News, Colleges and Schools Love WordPressMU, Viddler Meets WordPress, Theme Buyers Beware, Columns in Blog Posts, Feeds Without Plugins : The Blog Herald
  5. indexius - Quality web resources » Blog Archive » Going for a new domain for you’re wordpress blog?
  6. Around the Web in Blogging | BlogOnExpo
  7. Blogbuster: блоги, blogs, blogging, RSS, Wordpress, Ñ?оциальное
  8. Moved hosting | Technology Blog by Colbert Low
  9. pet peeves with modern web design: design reboot (Part 4) | Balaji's Blog
  10. Migrate/move your WordPress blog to a new domain/server | ...Clueless
  11. E-Tail.be , we zijn ermee vertrokken
  12. Blog Moved! | Quiverfull Family
  13. How to move your Blog to a new Domain | Blog
Pepperjam
SEO Book Tools
Free Google Traffic
BLVD Status
Directory Journal
SearchEngineWatch
Hosting by:
Hosted by MediaTemple Grid Services