Redirect Main Domain to Sub Domain using .htaccess

January 22nd, 2010

There are two simple ways to redirect your main domain to any sub-domain.

1. Using php / html redirect
2. Using .htaccess

In this article i will show you how to redirect using .htaccess. If you already have an .htaccess file in your root folder then open to edit it, else create a new one using note pad and then cut and paste the code below.

Note: Please change the url to your own domain name.

RewriteEngine On
Options +FollowSymlinks
RewriteCond %{HTTP_HOST} ^(www.)?example.com$ [NC] 
RewriteRule ^ http://subdomain.example.com [R,L]

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

Leave A Comment