I'm having a Magento multistore setup and i'm sending all non www requests to www in the .htacces with the rewrite:
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
I'm using a sub domain for testing new websites and for this sub domain I don't need this rewrite. Therefore I use:
RewriteCond %{HTTP_HOST} ^sub\.domain\.com [NC]
RewriteRule ^(.*) - [L]
Only problem now is that when I go to http:// sub.domain.com it works, but when I go to a category or product for example http:// sub.domain.com/cat1 or http:// sub.domain.com/product-red.html it doesn't work any more and I get a "Not Found" message.
What do I need to add to the code so it excludes the whole sub domain, including everything after the / ?
Don't use a separate rule to ignore all requests for subdomain like that otherwise Magento's routing rule will also be skipped. Instead tweak your www
rule like this to ignore subdomain:
RewriteCond %{HTTP_HOST} !^(www|sub)\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}/$1 [R=301,L,NE]