Skip to content

Instantly share code, notes, and snippets.

@david4worx
Created December 5, 2012 19:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save david4worx/4218973 to your computer and use it in GitHub Desktop.
Save david4worx/4218973 to your computer and use it in GitHub Desktop.
.htaccess basic auth
RewriteEngine On
RewriteBase /
# DO match the following url(s)
SetEnvIf Request_URI ^(?!<insertYourUrlHere>$) noauth=1
# the auth block
AuthName "Please login."
AuthType Basic
AuthUserFile <insertYourPasswordFileHere>
# Here is where we allow/deny
Order Deny,Allow
Satisfy any
Deny from all
Require valid-user
Allow from env=noauth
RewriteEngine On
RewriteBase /
# DO match the following url(s)
SetEnvIf Request_URI ^(<insertYourUrlHere>$) doauth=1
# the auth block
AuthName "Please login."
AuthType Basic
AuthUserFile <insertYourPasswordFileHere>
# Here is where we allow/deny
Order Deny,Allow
Satisfy any
Deny from all
Require valid-user
Allow from env=doauth
@david4worx
Copy link
Author

RewriteEngine On RewriteBase /
# DO match the following url(s)
SetEnvIf Request_URI ^(<insertYourUrlHere>$) doauth=1
# the auth block
AuthName "Please login."
AuthType Basic
AuthUserFile <insertYourPasswordFileHere>

# Here is where we allow/deny
Order Deny,Allow
Satisfy any
Deny from all
Require valid-user
Allow from env=doauth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment