301 Redirect WordPress Posts To New Domain

by Nish Vamadevan on 01/04/2008 · 33 comments

301 Redirect is considered as a permanent redirect compared to a 302 redirect which is temporary. Therefore when moving wordpress to a new domain, it is a good idea to redirect all the posts to the new domain.

This way all the search engine records will be kept intact and this means you won’t lose any traffics / hits to the website.

This doesn’t mean redirecting from fnode.com to nish.com, it will also redirect every single URL associated with fnode.com to nish.com.

For instance, if a user is looking for a particular post and goes to fnode.com, they will be redirected to the corresponding post on nish.com

Here is an example of one of the most popular post on the site…

http://www.fnode.com/2007/06/02/make-bisoncam-work-on-windows-vista/

When users clicks on the above link, they will be automatically redirect to

http://www.nish.com/2007/06/02/make-bisoncam-work-on-windows-vista/

This way, the user won’t notice the domain change because it is 99% directed via search engine or linked URL.

This method is also a good way to let GoogleBot to know that the domain has been moved permanently from fnode.com to nish.com

Here is the code below and I used which goes into the .htaccess file. All you got to do is to replace the URL to make it work with your own domain.

# BEGIN WordPress
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.fnode.com
RewriteRule (.*) http://www.nish.com/$1 [R=301,L]
# END WordPress

  • http://photographythoughts.wordpress.com John

    Where do I put the code exactly?

    I'm moving http://blog.photographythoughts.com
    to
    http://photographythoughts.wordpress.com

    The permalinks structure is kept intact. At this moment I've made a change to the singe post file as follows:

    But this only forwards to the main page.

  • http://photographythoughts.wordpress.com John

    Sorry the code didn't came along with the previous comment:

    " "

    Hope this works.

  • John

    Nish,

    What if I want to 301 posts from one wordpress domain to another domain with a different permalink structure?

  • http://www.nish.com Nish Vamadevan

    @John

    You need to do that on .htaccess file… You will only get access to that file if you host your own blog.

  • http://wcs.ofimdavarzea.com j. noronha

    Thanks a lot, this piece of code was a life savior. I've spent the last two days trying to accomplish this redirect with no success at all. Now it works like a charm.

  • http://www.nish.com Nish Vamadevan

    Glad to hear it!

  • http://www.frogstr.com frogstr

    Thanks buddy, that helped me make a smooth domain transition!

  • http://yiyd.com Josh

    First of all congratulation for such a great site. I learned a lot reading here today. I will make sure i visit this site more often so I can learn more.

  • http://www.jehzlau-concepts.com/ Jehzeel Laurente

    this is what I'm looking for. :) I tried it and it works in a snap :) Thank you so much ^_^

  • Pingback: How To: Move WordPress to a new Domain! | Design Woop | The Web Design and Development Blog

  • Adrain

    i am trying to redirect my site on wordpress.com e.g XXXX.wordpress.com to my self hosted blog. now there is no way i can alter wordpress.com blog. Please help me

    • http://www.nish.com Nish Vamadevan

      You can't do it, you need to have access / .htaccess…

  • Anand Srinivasan

    Hi Nish

    Amazing post..Thanks a lot..Where do I post these 5 lines of code?

    Also, will this help in retaining all the in-links that I have built for my older site?

  • http://www.nish.com Nish Vamadevan

    Anand, You should be able to retain everything and it will be a seemless transformation for the users… All info goes into the .htaccess file.

  • http://www.machetemag.com Mark Jones

    Cheers – this is the best solution ever.

  • http://johnsardine.com/ João Sardinha

    Thank you so much, you just made my day!

  • http://www.eibusiness.com Debbie Hulbert

    I have a self-hosted wordpress site that I am trying to do a redirect for all comments. Essentially, I have the WP site with a 301 redirect for all posts to go to a different site – blog needed a different header than the rest of the site. The posts and top level blog page seem to redirect just fine, however, the comments revert to the original site and not the redirect. Only top level menu redirects. Individual post titles and comments do not redirect. Any ideas?

    • http://www.nish.com Nish Vamadevan

      Can you show me an example?

  • Pingback: Jumping to xfishie.tk | Meow Meow Fish

  • http://www.theawood.com Thea Wood

    Nish,
    Your post has me *almost* redirecting URL’s. Here’s my current state:

    Old blog: austinthea.wordpress.com
    New Blog: theawood.com (a WP themed site but Register.com hosted)

    My old posts have already been copied to the new site. Now I just need to do redirects from the old blog to the new blog postings.

    I found my htaccess folder in the register.com directory, where it has the default text. I tried two approaches: 1. replacing the default text with your code, and 2. adding it to the existing default code. In both cases, my old posts did *not* redirect to my new ones.

    Suggestions?

    • http://www.nish.com Nish Vamadevan

      Thea,

      I can see one of the blog is hosted at WordPress.com. For this to work, you need to have access to .htaccess in both servers. Do you have that access? If not, it is not possible.

  • http://www.theawood.com Thea Wood

    What is the navigational path to find the .htaccess file on WordPress if I’m logged into my WordPress account? I’m the blog owner.

    • http://www.nish.com Nish Vamadevan

      Thea, you will not have access to .htaccess on WordPress.com. AFAIK is it not possible on WordPress.com. My method only works, if you host you both blogs by yourself.

  • http://www.profesionalenseo.com/ Jhon Edison Bueno Martínez

    Thank You It works perfectly, now I migrate to my new domain without lose visitors…

  • Santosh

    Thanks, Very Useful :)

  • Gozanli

    hello, clear post but i have problem; I want to redirect my example.com/article/my_post_name to example2.com/my_post_name. What should i do?

    • http://www.nish.com/ Nish Vamadevan

      The following should work, and I have just tested it on my website…

      # BEGIN WordPress
      RewriteEngine On
      RewriteCond %{HTTP_HOST} ^www.example.com/article
      RewriteRule (.*) http://www.example2.com/$1 [R=301,L]
      # END WordPress

  • thangarajus

    Hi Nish, i tried your tutorial but my problem is only redirecting my homepage and wp-admin page of old domain to new domain but other internal pages are not redirect to new domain. All my permalink and other setting are same as old domain. pls suggest me solution. 

    need to redirect to new permalink site (ex. oldsite/2009/10/12/postname to newsite/catname/postname) is there any plugin for wordpress.

  • http://www.facebook.com/ricardocorreianunes Ricardo Nunes

    SOLVED!!!! I’ve try about 12 other harder tutorials but no result!! Only redirect the homepage, but this is the FINAL SOLUTION!!! THANKS

  • Pingback: wisefaq.com » Moving WordPress to a new domain.

  • Miri Shehu

    hello and thanks for the info.
    I’m using a wordpress site with costum post types and i want to redirect to new domain that doesn’t use costym post types.
    i mean: http://www.domain1.com/articles/some-post to go to http://www.domain2.com/some-post

    • http://www.nish.com Nish Vamadevan

      Miri, It is only possible from Hosted Site to Hosted Site and not possible from WordPress.com because, you will need access to .htaccess file which WordPress.com do not provide.

  • mortenmunchow

    i did this for my http://www.on-coffee.com to http://www.coffee-mind.com but it does not work for on-coffee.com (without the ‘www’ in front). How could I also have the ‘non-WWW’-version redirected?

Previous post:

Next post: