R
R
Rocker_dead2016-12-20 00:03:12
htaccess
Rocker_dead, 2016-12-20 00:03:12

How to redirect to mobile version in htaccess and ignore images?

This redirect works:

RewriteCond %{HTTP_ACCEPT} "text/vnd.wap.wml¦application/vnd.wap.xhtml+xml" [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} "acs|alav|alca|amoi|audi|aste|benq|blac|blaz|brew|cell|cldc|cmd-" [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} "dang|doco|erics|hipt|inno|ipaq|java|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-" [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} "maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|opwv" [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} "palm|pana|pant|pdxg|phil|pluc|port|prox|qtek|qwap|sage|sams|sany" [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} "sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo" [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} "teli|tim-|tsm-|upg1|upsi|vk-v|voda|w3cs|wap-|wapa|wapi" [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} "wapp|wapr|webc|winw|winw|xda|xda-" [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} "up.browser|up.link|windowssce|iemobile|mini|mmp" [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} "symbian|midp|wap|phone|pocket|android|mobile|pda|psp" [NC]
RewriteCond %{HTTP_COOKIE} !ver=full; [NC]
RewriteRule ^(.*)$ http://www.m.site.ru/$1 [NC,L]

However, it also redirects image urls. And all the pictures are on the main domain. How to correct this code? Or suggest a better option please

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Arman, 2016-12-20
@Rocker_dead

To add to RewriteRule?

RewriteCond %{REQUEST_URI} !^.*\.(jpg|css|js|gif|png)$ [NC]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question