Reputation: 41
How can I redirect mobile users to /mobile/ directory?
This code work for me only if users start navigate from main path (http://www.mywebsite.it) but if they click on a link on facebook (http://www.mywebsite.it/news/title-news/123.html) they reach the non-mobile version...
RewriteCond %{HTTP_USER_AGENT} blablabla [NC]
RewriteRule ^$ http://www.mywebsite.it/mobile [R=302,L]
If I change the second line width this one:
RewriteRule ^ http://www.mywebsite.it/mobile [R=302,L]
the redirection is ok but the mobile version of website is inaccessible (images not displaying, jquery mobile doesn't work...)
Who can help me?
----|----
And if I want to exclude a subfolder? My back-end is responsive but now it is impossible to access at http://www.mywebsite.it/admin because .htaccess redirect to mobile version!
Upvotes: 1
Views: 68
Reputation: 41249
You have to exclude your existent files from the rule :
#--exclude existent files--#
RewriteCond %{REQUEST_URI} !\.(css|js|jpe?g|gif|png)$ [NC] RewriteCond %{HTTP_USER_AGENT} blablabla [NC]
RewriteRule ^(.*)$ http://www.mywebsite.it/mobile/$1 [R=302,L]
Otherwise the Rule redirects them to the mobile directory.
Upvotes: 1