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:
- Put up a
robots.txton the new domain with the following contents:User-agent: * Disallow: /
- Copy the database and files to the new domain.
- Edit
wp-config.phpto have the right database settings, and add the following lines, replacing sample.com with the right domain:define('WP_SITEURL', 'http://www.example.com'); define('WP_HOME', 'http://www.example.com');
- 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).
- 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.
- Once you're done, and you've checked everything works twice:
- Remove the
robots.txtfile. - On your old blog, add the following line to your apache
.htaccessor vhost-config:Redirect 301 /blog/ http://www.newdomain.com/
- Remove the old blog code and database.
- 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!






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?
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.
@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.
Do you have upload the .mo-File for display in english?
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.
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.
@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 :)
May I know why I have to remove robots.txt file while moving wordpress blog to new domain?
@Adam: Just delete it, or remove the Disallow line.
@Joost,
thx a lot. It seems a lot easier than I thought. Implementing this on my blog was quicker than writing my post above.
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.
@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.
@Frank & JLH: haven't had time to test it yet...
@Frank: if you need help, let me know!
Shouldn't Step 8 begin with "On your old blog..." ?
Offtopic: Best wishes.. haha.. got an update via plaxo.
@stephen: yes indeed!
@rxbbx: heh, thanks! It's tomorrow though :-)
@stephen: updated.
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.
@Cody: yes I think so... You can leave out some of the steps of course, like the search & replace and the 301 redirect.
Yes ;)
Joost, I think this must be the basic knowledge of every webdesigner :)
@Henri: well... that goes for about 90% of SEO in my opinion :)
Sounds easy enough. Good to know if you "accidentally" choose the wrong name.
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]
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.
@jimmy: the simple one line 301 redirect I gave does exactly the same as your rewrite lines ;)
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.
Good point Roger, I use aweber too, so I'll keep it in mind!
@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
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!
@Frank: thx for delivering such great service to my readers!
@Marc: at your service :)
@Joost de Valk: I'm a reader od your blog! Thx.
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.
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
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?
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.
@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.
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?
@gofree: what where you doing when you got this error?
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???
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.
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.
I still don't know what you're trying to do... Email me on joost at this domain and we'll work it out.
now sending email to you...
very good tips. using it to transfer my blogger posts into the new site. thank you!
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?
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...)
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.
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?
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?
Very nice tutorial. I spend hours to find the solution and you make it looks easy to do.
http://www.tldsco.com
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 ?
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.
thanks it really helped moving my domain! Great tutorial!
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!
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.
Thanx joost. Got here exactly what i was looking for.
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/
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!
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.
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?
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.
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!!
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.
Thank you for the information!
Always my number 1 ressource for my wordpress questions and you don't disappoint.
A quick question:
what I would like to achieve is actually moving my blog on a subdomain of my current URL. Now, the process you describe means that the current domain has to be a wordpress install:
1) What if I want the current domain to be only a non-wordpress page? Can I still redirect the current permalinks without hassle?
2) If I maintain a wordpress install on my current domain (choosing a CMS oriented theme), how can I ensure that only the permalinks of my current blog are redirected, but not the newer entries I would add?
Many thanks for your help!
Cheers,
Paul.
If someone can't login to WP after adding
define('WP_SITEURL', 'http://www.sample.com/');
define('WP_HOME', 'http://www.sample.com/');
try removing the triling slash, that worked for me.
You're right, that's the correct syntax, changed it in the post!
Hi,
Like the list. How about creating one:
Titled: Copy your WordPress blog to a new domain in 10 steps!
Subtitled: The Idiots Guide to copying your existing blog to a new domain, with all the existing data, tables, etc etc
This is one IDIOT that could really use a list like this!!!
Thanks
Brian
sorry... I meant...
using an existing blog template and data and moving/migrating/copying (whatever its called) to a new domain to have two blogs at different www. locations
Not for duplicate content, but for duplicate layout, design, style, tables etc. and content which can easily be changed for new content...
Sorry for the clumsy explanation!
Hi,
thanks for this great write-up.
I've moved my blog to a new domain name but when I'm using the url without the www part, a blank page appears. I've regenerated my permalinks, and I don't know why it seems to accept only the url with the www part and not the no-www one.
I've also changed the settings in the Wordpress admin panel but to no avail :(
Could you please suggest me something?
Thanks indeed.
Hello, i have installed wordpress ta domain.org, but i need to have domain.com as main domain (domain.org i wolud lik to be parked) of that installation. If ponit name servers (domain.com) to hosting where is wordpress installed would by blog work??
What exactly does "On your old blog, add the following line to your apache .htaccess or vhost-config:
Redirect 301 /blog/ http://www.newdomain.com/Remove the old blog code and database." mean?
If I open .htaccess with DW then there is just a bit of text. Should I remove all of it and replace with that?
My feedburner account has now stopped working and gives me an error. Any ideas?
Hello,
thank you very much for this post! It helps me a lot!
I couldn't get this to work for the longest time. (It appeared to work, but the admin panel just kept redirecting back and forth between and new and old domains) I deleted the 'cache' folder and everything started working fine.
Hi Joost,
I just moved a website from my subdomain to a new domain. Everything's shifted well, except that I can't change the permalink structure anymore. Nothing except the homepage shows if I do. I have tried everything...manually changing .htaccess, moving install with default permalink, but no effect. Also the domain.com/index.php keeps going to index.html which is the current website page.
I am hosting this new domain on the client's dedicated server.
Any pointers about this problem will be helpful.
Thanks in advance.
After what period can you remove the redirect lines in the .htaccess?
Thanks so much for this hint. I had just migrated to a new domain but didn't know how to do the search and replace. Perfect!!!
Now, how do you tell Google that the old domain is inactive?
Thank You so much! I have been searching for those two lines of code for the wp-config file! Thanks to you I found them and have successfully graduated from a co.cc domain to a .com domain! My utmost gratitude!