.htaccess Http_user_agent Not Working
Solution 1:
You are using a negation here, so you have to lose the [OR]
and include a !
:
RewriteCond %{HTTP_USER_AGENT} !(Android|iPod|iPhone|iPad) [NC]
What your rule is doing is redirecting when it is not the correct referer and is not a mobile user-agent. What you had before:
RewriteCond %{HTTP_REFERER} !^http://(direct\.|www\.)?mysite\.com/.*$ [NC]
RewriteRule .*\.(mp4)$ http://www.mysite.com [R,NC]
Is saying: If the referer isn't from http://(direct\.|www\.)?mysite\.com/
, then redirect the .mp4 request to http://www.mysite.com
. The logic here is if the referer is correct, they can get to the mp4 file just fine.
To follow the logic where you say if the referer is correct or if the user-agent is mobile, serve the mp4, you need to negate the entire thing. (A or B)-> do something
, to !(A or B) -> don't do something
, which translates to: !A and !B -> don't do something
.
So you need to negate the mobile user-agent check and instead of an OR use an AND (which is what is default for rewrite conditions).
Solution 2:
Try
RewriteCond %{HTTP_USER_AGENT} (Android|iPod|iPhone|iPad) [NC,OR]
Post a Comment for ".htaccess Http_user_agent Not Working"