Skip to content

Instantly share code, notes, and snippets.

@teknikqa
Forked from tomschlick/gist:1397070
Last active April 3, 2016 12:15
Show Gist options
  • Save teknikqa/9c3588ce530d07ee01fb to your computer and use it in GitHub Desktop.
Save teknikqa/9c3588ce530d07ee01fb to your computer and use it in GitHub Desktop.
Conditional htpasswd. htaccess declarations to set password for only certain files.
#allows a single uri through the .htaccess password protection
SetEnvIf Request_URI "/testing_uri$" test_uri
#allows everything if its on a certain host
SetEnvIf HOST "^testing.yoursite.com" testing_url
SetEnvIf HOST "^yoursite.com" live_url
Order Deny,Allow
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /path/to/your/.htpasswd
AuthGroupFile /
Require valid-user
#Allow valid-user
Deny from all
Allow from env=test_uri
Allow from env=testing_url
Allow from env=live_url
Satisfy any
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment