I`ve been tasked to modify the redirect to a mobile site in .htaccess file to redirect only the main page. The problem is that the main folder includes many subfolders that are pages of their own and they wrongly redirect to the main site mobile version.

This is the code:

```
 RewriteOptions inherit
<IfModule mod_expires.c>
ExpiresActive On
#ExpiresDefault "access plus 10 second"
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
# Webfonts
ExpiresByType application/vnd.ms-fontobject         "access plus 1 year"
ExpiresByType font/eot                              "access plus 1 year"
ExpiresByType font/opentype                         "access plus 1 year"
ExpiresByType application/x-font-ttf                "access plus 1 year"
ExpiresByType application/font-woff                 "access plus 1 year"
ExpiresByType application/x-font-woff               "access plus 1 year"
ExpiresByType font/woff                             "access plus 1 year"
ExpiresByType application/font-woff2                "access plus 1 year"
</IfModule>

<filesMatch ".(js)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

#### MOBILE REDIRECTION START

RewriteBase /

# Check if m=1 is set and set cookie 'mobile' equal to 1
RewriteCond %{QUERY_STRING} (^|&)m=1(&|$)
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ - [CO=mobile:1:%{HTTP_HOST}]

# Check if m=0 is set and set cookie 'mobile' equal to 0
RewriteCond %{QUERY_STRING} (^|&)m=0(&|$)
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ - [CO=mobile:0:%{HTTP_HOST}]

# cookie can't be set and read in the same request so check
RewriteCond %{QUERY_STRING} (^|&)mobile=0(&|$)
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ - [S=1]

# Check if this looks like a mobile device

# Check if we're not already on the mobile site
# Check to make sure we haven't set the cookie before
# Now redirect to the mobile site
RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC,OR]
RewriteCond %{HTTP:Profile}       !^$
RewriteCond %{HTTP_HOST}          !^m\.
RewriteCond %{HTTP:Cookie}        !\mobile=0(;|$)
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ http://m.siteurl.com [R,L]

#### MOBILE REDIRECTION END

```

Can someone help me where and how to put the exceptions for folders(sites) other than the main one.