Forum Moderators: phranque
For instance, I have WebmasterWorld setup this way:
RewriteCond %{HTTP_HOST} ^72\.3\.232\.139 [OR]
RewriteCond %{HTTP_HOST} .mobi [OR]
RewriteCond %{HTTP_HOST} .cn [OR]
RewriteCond %{HTTP_HOST} ^webmasterworld\. [NC,OR]
RewriteCond %{HTTP_HOST} ^mail\.webmasterworld\. [NC]
RewriteRule ^(.*) [webmasterworld.com...] [R=301,L]
So essentially, I want to do a not www.webmasterworld.com, and redirect with a hard 301 to the main domain.
# If not exactly "www.webmasterworld.com" (or blank if HTTP/1.0)
RewriteCond %{HTTP_HOST} !^(www\.webmasterworld\.com)?$
# externally redirect to www.webmasterworld.com
RewriteRule (.*) http://www.webmasterworld.com/$1 [R=301,L]
[added] Accepting a blank hostname prevents an infinite redirection loop if the request is made with HTTP/1.0 and the Host header is not sent. [/added]
Jim
[edited by: jdMorgan at 10:48 pm (utc) on Sep. 17, 2008]