Reputation: 7906
I am trying to do this when ever i hit from a mobile i redirect to mobile website and from pc means normal website. But the conditions dont work properly.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} "{android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile}" [NC]
RewriteRule ^(.*)$ http://localhost:8080/home.html [L,R=301]
RewriteCond %{HTTP_USER_AGENT} "!{android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile}" [NC]
RewriteRule ^abc.html$ /abc1.html [R=301,L]
RewriteRule ^1.html$ /2.html [R=301,L]
</IfModule>
when i hit localhost from a mobile device i get mobile website properly, but if i give localhost/abc.html the second condition comes into picture, but it actually should go to mobile website. Any problem with the code?
Upvotes: 0
Views: 191
Reputation: 10878
Not so much an ans, but a set of points re your approach:
RewriteBase /
as the engine sometime gets confused if you don'tLastly and most importantly, why are you doing a 301 redirects instead of a simple internal redirect which then does not require the extra round trip and/or browser caching of 301s?
RewriteCond %{HTTP_USER_AGENT} (android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile) [NC]
RewriteRule ^(.*)$ mobile/home.html [L]
RewriteRule ^abc.html$ abc1.html [L]
RewriteRule ^1.html$ 2.html [L]
Upvotes: 1