Exclude one folder in htaccess protected directory

前端 未结 5 1730
猫巷女王i
猫巷女王i 2020-12-30 00:20

I have a directory protected by htaccess. Here is the code I use now:

AuthName \"Test Area\"
Require valid-user
AuthUserFile \"/***/.htpasswd\"
AuthType basi         


        
5条回答
  •  天涯浪人
    2020-12-30 00:50

    According to this article you can accomplish this by using SetEnvIf. You match each of the folders and files you want to grand access to and define an environment variable 'allow' for them. Then you add a condition that allows access if this environment variable is present.

    You need to add the following directives to your .htaccess.

    SetEnvIf Request_URI "(path/to/directory/)$" allow
    SetEnvIf Request_URI "(path/to/file\.php)$"  allow
    Order allow,deny
    Allow from env=allow
    Satisfy any
    

提交回复
热议问题