redirect sub domain in htaccess file I have tried a number of ways to try to redirect a sub url in my htaccess file with very little progress, and I know I am doing it correctly but for some reason it just is not working, and as far as I can tell there is no module that can do this. I am simply trying to direct a sub domain to the main domain.

This is the code I am using.

  RewriteBase /
  RewriteRule ^red.sitename.com$ http://sitename.com/ [R=301,L]


Now I have red somewhere that you have to do it this a certain way when clean urls is enabled and this is suppose to be the correct way but it is not working.
The piece you are missing is RewriteCond.

This should redirect just the subdomain

RewriteBase /
RewriteCond %{HTTP_HOST} ^red\.sitename\.com$ [NC]
RewriteRule ^(.*)$ http://sitename.com/$1 [L,R=301]


Note also that the separator needs to be escaped as \. to prevent it from being used as a single character match in the pattern.  The [NC] also tells Apache to ignore case during the match.