I know that this question has a been asked many times, but I still can’t figure out what’s going wrong in my code.
I have a stylesheet link on my HTML
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
And I want to redirect to another file if the user is on a mobile device.
I did it this way:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/style.css$
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|webos|googlebot-mobile" [NC]
RewriteRule (.*) /mobile.css [L,R=302]
My files are all in the root of a subdomain, so I guess that the rule !^/style.css$ should be correct.
When I try to reach /style.css, I don’t have a redirection, but when a try to reach /, Firefox tells me there is a redirection loop.
Do I miss something?
Thanks
It’ll work if you use Rewrite instead of Redirect: