Wild Card Domain Redirection

Wild Card Domain Redirection

Target

Setting up wild card to redirect *.yourdomain.com to yourdomain.com i,e. anything.yourdomain.com will be 
redirected to yourdomain.com

First create a .htaccess file in the document root folder of the domain yourdomain.com. so anything.yourdomain.com will be redirected to yourdomain.com and below is the .htaccess file to achieve this condition.

DirectoryIndex index.html
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.yourdomain\.com [NC]
RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]

Anything that stats with *.domain.com eg: xxx.domain.com xyz.domain.com will be redirected to domain.com

Reference

URL: http://www.webmasterworld.com/forum92/3660.htm
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s