Forum Moderators: phranque

Message Too Old, No Replies

htaccess subdomain redirect

         

karmargin

1:36 pm on Apr 12, 2007 (gmt 0)

10+ Year Member



I've got a domain with many subdomains, eg. [sub1.domain.com....] I need to redirect all of them to a directory on the root domain, eg: [domain.com...]

is there a 301 code that i can place on the root directory to redirect all the subdomains?

jdMorgan

3:30 pm on Apr 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is simply the standard non-www to www- domain canonicalization redirect previously discussed many times:

# If HTTP hostname header is non-blank
RewriteCond %{HTTP_HOST} .
# and if requested hostname is NOT www.example.com
RewriteCond %{HTTP_HOST} !^www\.example\.com
# Redirect to www.example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

Jim