I have domain.com.
I also have m.domain.com.
If I try to access m.domain.com from a desktop, I want to redirect the user to domain.com UNLESS the user is explicitly trying to access a specific folder (in my case: wp-admin for login to wordpress).
Part of my .htaccess has the following code which properly detects and handles the redirect but I am stuck on the folder exclusion portion.
#Options +FollowSymlinks -MultiViews
#insert folder exclusion
#RewriteCond %{HTTP_USER_AGENT} ^.*(MSIE.*Windows\ NT|Lynx|Safari|Opera|Firefox|Konqueror) [NC]
#RewriteCond %{HTTP_USER_AGENT} !(^.*(Opera\ Mini|SymbianOS|Mobile)) [NC]
#RewriteCond %{HTTP_HOST} ^(\w+)\.domain\.com [NC]
#RewriteRule .* http://domain.com/ [R,L]
If you want to redirect when the root is accessed, then perhaps you could add the following before the last line with the RewriteRule.
This will then only process the redirect if you accessed http://m.domain.com/ directly.
The above will redirect only if the folder being access is not in the list (wp-admin, etc, etc).