Print

Printed September 9, 2010 from B&T's Tips & Scripts
http://tips-scripts.com


Undefined subdomains

If you use wildcard subdomains so that any subdomain will go to your domain name, you can use this code to strip off the subdomain.   The url will then show your domain name without the undefined subdomain.

The www subdomain and access by an IP address is excluded.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.+)\.([^\.]+\.[^\.]+)$
RewriteCond %1 !^(www)$
RewriteCond %{HTTP_HOST} !^[0-9\.]+$
RewriteRule ^(.*)$ http://%2/$1 [R,L]