문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top