Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What's the most elegant way to allow only Apple OS users onto a website and redirect all others to default page?

The following seems kind of award.

BrowserMatchNoCase Windows bad_os Order Deny,Allow Deny from env=bad_os

ErrorDocument 403 Order Deny,Allow Allow from all

share|improve this question
It will seem kind of awkward because - with all due respect - it's kind of an absurd idea. You can try all these hacks but webservers and HTML itself are designed to be inclusive of different platforms, not exclusive. – RobM Nov 16 '10 at 9:06
I agree with you in general but I wouldn't ask if I didn't have a good reason to keep windows out. – Yvonne Nov 16 '10 at 15:16

An easy way to do this is to use the BrowserMatchNoCase directive, which will allow you to do a case insensitive search of the user agent environment variable. I.e.,

BrowserMatchNoCase apple platform=macintosh
BrowserMatchNoCase mac platform=macintosh

RewriteCond %{ENV:platform} !macintosh
# Don't actually rewrite to anything (-); just return 403
RewriteRule ^.* - [F,L]

(as taken from the mod_setenvif documentation). You can then use this variable to redirect to different pages. This would be cleaner if you have many conditions to check (and I have no idea how many you will need). If you have only a few, or want to chain them together in what could become a potentially messy string, you could use mod_rewrite directly. The following insures that apple and mac are not in the user agent, and redirects non-matching requests.

RewriteCond %{HTTP_USER_AGENT} !apple [NC]
RewriteCond %{HTTP_USER_AGENT} !mac [NC]
# Don't actually rewrite to anything (-); just return 403
RewriteRule ^.* - [F,L]

This uses the [NC] flag for RewriteCond which indicates that the searches be case insensitive--again, a necessity if you're not sure what conditions you'll be matching. The F flag in the RewriteRule will return a 403 Forbidden.

Pay heed to Robert Moir's comment, though, because this relies on the browser sending a matching user agent--which isn't even close to being reliable. This should get you started, and you can additional matches as you find them.


share|improve this answer
Andrew thanks. That seems to be what I'm looking for. Not being the programmer you think I am, what do I need around it to make this work? How would a sample look like sending Windows user to a default page. Do you know or can you guide me further? – Yvonne Nov 16 '10 at 15:29
Updated my answer to reflect your request. Also provided alternative method using RewriteCond from mod_rewrite. I haven't tested these to the dot, but they should be what you're looking for. – Andrew M. Nov 17 '10 at 5:21
Great, gonna have a go at it and test this. Thanks for your time. – Yvonne Nov 17 '10 at 9:28

You can use mod_rewrite and check HTTP_USER_AGENT, you will need a list of iOS user-agents.

Also, theres something called Apache Mobile Filter:

I have not used it yet, but looks nice.

share|improve this answer
Thanks for the link, the answer seems to be deep down there. Will check it. – Yvonne Nov 16 '10 at 15:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.