Skip to content

Instantly share code, notes, and snippets.

@archatas
Created July 26, 2017 23:19
Show Gist options
  • Save archatas/8ea19b61a06f1a77629386780758732a to your computer and use it in GitHub Desktop.
Save archatas/8ea19b61a06f1a77629386780758732a to your computer and use it in GitHub Desktop.
Allow access to a website only to specific user agents or visitors with authentication credentials
SetEnvIf User-Agent ^VipAgent1 vip_agent
SetEnvIf User-Agent ^VipAgent2 vip_agent
Order Allow,Deny
Allow from env=vip_agent
AuthType Basic
AuthName "Protected Login"
AuthUserFile /path/to/htpasswd
Require valid-user
Satisfy any
#...
LoadModule authn_file_module libexec/apache2/mod_authn_file.so
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule setenvif_module libexec/apache2/mod_setenvif.so
#...
AllowOverride All
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment