Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top