DNS and mod_rewrite not-collaborating
- by ???? ?????????
Hello,
I have added a CNAME record to my DNS on my CentOS server to redirect subdomain.mydomain.com to another server.
I also use mod_rewrite to rewrite mydomain.com to www.mydomain.com:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]
this is placed into .htaccess in the root public html directory
Now, the problem is that whenever I lookup subdomain.mydomain.com it redirects me to www.mydomain.com
I tried adding another RewriteCond:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteCond %{HTTP_HOST} !^subdomain\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]
But it didn't help...
Anyone has some ideas?