Home » Android » Permit only iphone/ipad/ipod/android to access files in directoy, all others redirect to google.com

Permit only iphone/ipad/ipod/android to access files in directoy, all others redirect to google.com

Posted by: admin June 15, 2020 Leave a comment

Questions:

I have a directory of MP3 files that I would only like android, iphone, ipad, ipod devices to access, all others be redirected to www.google.com or given a 403 “Forbidden”

I would like to do this with htaccess by reading the user agent.

I have attempted modifying code I found on the net that involved SetEnvIfNoCase or RewriteCond.

Currently I have no code near working and now reaching out for help. Thanks!

Also, I have attempted to modify the code found at mobile site redirect to desktop version using .htaccess but I couldn’t get it correct..

EDIT: Found the solution!

    SetEnvIf User-Agent "Android" allow_ua
    SetEnvIf User-Agent "iPhone" allow_ua
    SetEnvIf User-Agent "iPad" allow_ua
    SetEnvIf User-Agent "iPod" allow_ua
    Order deny,allow
    deny from all
    allow from env=allow_ua
How to&Answers: