3

Is it possible to restrict a domain to only allow visitors using a specific browser?

I'm building an app and it's only been tested in Chrome so far so I only want to allow Chrome users during Beta testing. Basically, I want to white-list browsers as I go through testing. Any suggestions on the approach I should would be greatly appreciated.

Andrew
  • 2,691
  • 6
  • 31
  • 47
  • 2
    Why not just make it work in all browsers anyway? It's not hard, honest! – Niet the Dark Absol Jun 24 '13 at 16:56
  • it is possible... but no one is gonna write the code for u – cliffbarnes Jun 24 '13 at 16:56
  • http://stackoverflow.com/q/7372551/522479 and Chrome's UA contains the keyword `chrome` for identification. – Cobra_Fast Jun 24 '13 at 16:56
  • @Kolink you must not work with IE much do you. LOL – Panama Jack Jun 24 '13 at 17:03
  • @Pjack Erm, actually IE is my primary browser. Never had a problem with it. Firefox on the other hand is giving me more headaches than IE6... – Niet the Dark Absol Jun 24 '13 at 17:04
  • 1
    Chrome all the way... I just hate how even in IE9, I need custom CSS for opacity, gradients, etc.. – Andrew Jun 24 '13 at 17:12
  • @Andrew agreed. Chrome is my primary browser. I hate IE and I'm a MS person otherwise. If not for FF, Chrome and others, MS would have never updated their browser. It took them years to get what Chrome has always had in IE 10. 10 is much better compliance than previous versions. Thank god for competition and Google. :) – Panama Jack Jun 24 '13 at 17:25

2 Answers2

2

Yes you can.

The browser that is accessing the page is in the _SERVER array.

If you find that the accessing browser is not Chrome, then just send a 404 header.

Naftali
  • 144,921
  • 39
  • 244
  • 303
0

You can block all other useragents with a relevant error message using .htaccess

Put this in .htaccess in root of your site:

ErrorDocument 503 "Your must use Chrome to access this site"
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^(Mozilla.*|Safari.*|Other.*)$ [NC]
RewriteRule .* - [R=503,L]
Don King
  • 301
  • 2
  • 9