301 Redirect WordPress Posts To New Domain

by Nish Vamadevan on 01/04/2008 · View 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 nishv.com to fnode.com, it will also redirect every single URL associated with nishv.com to fnode.com.

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

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

http://www.nishv.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.fnode.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 nishv.com to fnode.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.nishv.com
RewriteRule (.*) http://www.fnode.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

    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.

  • 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?

  • John

    Nish,

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

  • http://www.fnode.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://www.nishv.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://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.fnode.com Nish Vamadevan

    Glad to hear it!

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

    Glad to hear it!

  • http://www.frogstr.com frogstr

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

  • 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://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 ^_^

  • 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 ^_^

  • http://designwoop.com/2009/11/how-to-move-wordpress-to-a-new-domain/ How To: Move WordPress to a new Domain! | Design Woop | The Web Design and Development Blog

    [...] searching around I came across a great post from Nish Vamadevan over at fnode.com where he explains how to do this. On the root directory of your old domain, you will need to create [...]

  • 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

  • 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.fnode.com Nish Vamadevan

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

  • http://www.fnode.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?

  • 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.fnode.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.fnode.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.

blog comments powered by Disqus

Previous post:

Next post: