Created
February 5, 2018 04:11
-
-
Save guoxiangke/b33de380bddda88d5b7b35fd35e2cef3 to your computer and use it in GitHub Desktop.
Exclude one url from Apache .htaccess password protected site
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
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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
需求:开发期间站点需要.htpasswd保护,但是一个页面contact-us页面,需要被访问到。
也可以放在 /etc/apache2/sites-enabled/vsitesname.conf的Directory括号内!
参考链接:https://serverfault.com/questions/725004/exclusion-of-a-protected-sub-url-does-not-work-on-apache-2-4
其他无效链接:
https://gist.github.com/justinkelly/1565033
https://stackoverflow.com/questions/13950207/how-to-make-basic-auth-exclude-a-rewritten-url
https://gist.github.com/fmtarif/bf9503530a8d425ab8a2
https://stackoverflow.com/questions/8978080/htaccess-exclude-one-url-from-basic-auth
https://gist.github.com/tkhn/6899277