Skip to content

Instantly share code, notes, and snippets.

@guoxiangke
Created February 5, 2018 04:11
Show Gist options
  • Save guoxiangke/b33de380bddda88d5b7b35fd35e2cef3 to your computer and use it in GitHub Desktop.
Save guoxiangke/b33de380bddda88d5b7b35fd35e2cef3 to your computer and use it in GitHub Desktop.
Exclude one url from Apache .htaccess password protected site
AuthType Basic
AuthName "Authentication Required"
AuthUserFile /etc/htpasswd/.htpasswd
# Allow access to excluded diretories
SetEnvIf Request_URI /contact-us/ noauth=1
SetEnvIf Request_URI /*.css noauth=1
SetEnvIf Request_URI /*.js noauth=1
SetEnvIf Request_URI /*.ico noauth=1
SetEnvIf Request_URI /*.png noauth=1
SetEnvIf Request_URI /*.jpg noauth=1
SetEnvIf Request_URI /*.ttf noauth=1
SetEnvIf Request_URI /*.woff noauth=1
SetEnvIf Request_URI /*.gif noauth=1
<RequireAny>
Require env noauth
Require env REDIRECT_noauth
Require valid-user
</RequireAny>
@guoxiangke
Copy link
Author

@hangkala
Copy link

thank you, it works well

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