How to Redirect a folder to a Subdomain using .htaccess

January 7th, 2010

If you create a sub domain (e.g. from cPanel you will find that a subfolder ( in the same name has been added to the directory list. When you upload anything on the folder, it will reflect in the subdomain created. When you visit or, you will see that the content is the same.

There is nothing wrong with it, however from the view point of SEO and Search engines, this creates duplicate content, because… for search engines a folder is different from a subdomain. To avoid this issue we can simply add or edit the .htaccess. This will tell SE’s that the folder has been permanently redirected to the sub domain.

RewriteEngine on 
RewriteCond %{HTTP_HOST} !^
RewriteRule (.*)$1 [L,R=301] 

Please change (subdomain, example) as per your website.


  1. Redirect Main Domain to Sub Domain using .htaccess January 22nd, 2010

    […] Related article: 1. How to Redirect a folder to a Subdomain using .htaccess […]

Leave A Comment