Created
July 26, 2011 23:07
-
-
Save dennisfaust/1108309 to your computer and use it in GitHub Desktop.
Apache Basic Authentication for a Rewrite Condition Not a Directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Apache Basic Authentication for A Rewrite Condition not a Directory | |
# | |
# NOTE: Locations work off of URLs not directories | |
# | |
# Put this in your virtualhost block | |
# | |
<Location /YOUR_URL_PATH/> | |
AuthType Basic | |
AuthName "Authorization Required." | |
AuthUserFile /etc/httpd/conf/htpasswd | |
require valid-user | |
</Location> | |
RewriteCond %{LA-U:REMOTE_USER} !^$ | |
RewriteCond %{SCRIPT_FILENAME} ^/YOUR_URL_PATH/(.*) | |
#This is for HAProxy your destination will be different | |
RewriteRule ^.*$ http://127.0.0.1:86%{SCRIPT_FILENAME} [P,QSA,L] | |
# To create your password file... | |
# htpasswd -c /etc/httpd/conf/htpasswd | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment