How to redirect your subdomain to your new domain

March 23, 2007 by korokmu · 3 Comments
Filed under: Blogging, Tips 

Before this, I run this blog on free subdomain hosting from eizil.com under the address korokmu.eizil.com. After I had enough money, I bought a domain, Techlogs.net and asked the owner of eizil.com to use my domain with the hosting. Thanks to him because allowing me to still using his free service with my own domain. He had setup the add-on domain for me and everything worked smoothly.

After few days, I realized that my blog still can be accessed using the subdomain. Moreover, my blog is listed on Google and Yahoo with the address http://korokmu.eizil.com. And the fact that Google does not like duplicate content make me worry a little bit. I need to redirect the subdomain to my new domain. Before this, I've writen about redirecting a webpage using PHP. But this trick cannot be done because the index of korokmu.eizil.com and techlogs.net is the same. Therefore, I searched for other solution.

Luckily, I've found the .htaccess trick. It is just simple. What you need to do is, copy the code below in your .htaccess file and replace the domain.com with your domain.

HTML:
  1. Options +FollowSymLinks
  2. RewriteEngine on
  3.  
  4. RewriteCond %{HTTP_HOST} !^www.domain.com [NC]
  5. RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

And the most important part is, this redirection is search engine friendly. You can use this tool to check whether your redirection is friendly or not.

Related Links:
.htaccess forward subdomain to domain
Comprehensive Guide to .htaccess

3 Responses to “How to redirect your subdomain to your new domain”

  1. Eizil says:

    Salam bang,
    aku rasa ko kena tambah sket ko nyer rules tu, sebab rules ko akan redirect domain tu ke TLD…
    so contoh…
    http://www.korokmu.eizil.com/2007/03/23/how-to-redirect-your-subdomain-to-your-new-domain/
    patut dia akan gi ke
    http://www.techlogs.net/2007/03/23/how-to-redirect-your-subdomain-to-your-new-domain/
    baru cun… so nanti ko tambah aa rules tu erk… :) sekadar cadangan jer…
    okay… slamat²

  2. korokmu says:

    Owh, tak sedar. tapi nak buat macam mane ye?

  3. korokmu says:

    dah ok da. ade koflik dengan rules lain agaknye.

Leave a Reply