Quantcast
Channel: Password protect a specific URL - Stack Overflow
Viewing all articles
Browse latest Browse all 11

Answer by Jon Lin for Password protect a specific URL

$
0
0

You should be able to do this using the combination of mod_env and the Satisfy any directive. You can use SetEnvIf to check against the Request_URI, even if it's not a physical path. You can then check if the variable is set in an Allow statement. So either you need to log in with password, or the Allow lets you in without password:

# Do the regex check against the URI here, if match, set the "require_auth" varSetEnvIf Request_URI ^/pretty/url require_auth=true# Auth stuffAuthUserFile /var/www/htpasswdAuthName "Password Protected"AuthType Basic# Setup a deny/allowOrder Deny,Allow# Deny from everyoneDeny from all# except if either of these are satisfiedSatisfy any# 1. a valid authenticated userRequire valid-user# or 2. the "require_auth" var is NOT setAllow from env=!require_auth

Viewing all articles
Browse latest Browse all 11

Trending Articles