Here is a simple solution to exclude a subdomain from Apache mod_rewrite rules in the .htaccess. First of all I will explain the background of the case.
Background
In the forum we are using an extensive list of Rewrite rules for a perfect SEO including the domain.com to www.domain.com redirect. The rewrite rules used to achieve the the domain.com to www.domain.com redirect is as follows.
RewriteCond %{HTTP_HOST} !^www\.domain\.com
RewriteRule (.*) http://www.domain.com/$1 [L,R=301]
This is a recommended redirect rule for all those who prefer a www domain even though in google Webmaster tools you can specify the needed format. But this rule will affect all the urls resulting in one of my subdomains example.domain.com to be redirected to www.domain.com/example/ .
The solution
In order to resolve the problem just add the following to the top of the rewrite rules.
# Stop mod_rewrite processing if “example” subdomain requested
RewriteCond %{HTTP_HOST} ^example\.domain\.com
RewriteRule .* – [L]
Make sure it’s modified to reflect your domain and subdomain & ensure that it’s inserted after the fields like RewriteEngine On , RewriteBase / etc. All it will do is skip all the rewrites if the request is to example.domain.com.