Skip to content

Instantly share code, notes, and snippets.

@yudaprawira
Created September 1, 2016 04:03
Show Gist options
  • Save yudaprawira/c3203a82b366c219eb6c1da4ad89b19c to your computer and use it in GitHub Desktop.
Save yudaprawira/c3203a82b366c219eb6c1da4ad89b19c to your computer and use it in GitHub Desktop.
htaccess protect pretty url with password
# Do the regex check against the URI here, if match, set the "require_auth" var
SetEnvIf Request_URI ^/admin require_auth=true
# Auth stuff
AuthUserFile /home/juarain/.htpasswds/admin/.htpasswd
AuthName "Password Protected"
AuthType Basic
# Setup a deny/allow
Order Deny,Allow
# Deny from everyone
Deny from all
# except if either of these are satisfied
Satisfy any
# 1. a valid authenticated user
Require valid-user
# or 2. the "require_auth" var is NOT set
Allow from env=!require_auth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment