Apache 禁用重写路径的htaccess身份验证
我有以下带有基本身份验证和URL重写的.htaccess文件。我需要禁用特定路径的基本身份验证(例如,“/openaccess”),但重写首先发生,因此我无法使用SetEnvIf禁用身份验证。我发现的最接近的东西是,但它在Apache2.4.34上对我不起作用Apache 禁用重写路径的htaccess身份验证,apache,.htaccess,mod-rewrite,setenvif,Apache,.htaccess,Mod Rewrite,Setenvif,我有以下带有基本身份验证和URL重写的.htaccess文件。我需要禁用特定路径的基本身份验证(例如,“/openaccess”),但重写首先发生,因此我无法使用SetEnvIf禁用身份验证。我发现的最接近的东西是,但它在Apache2.4.34上对我不起作用 RewriteEngine On RewriteBase / RewriteRule ^index\.html$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUES
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /path/to/.htpasswd
Require valid-user
以下似乎有效:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /path/to/.htpasswd
SetEnvIf Request_URI /openaccess noauth=1
<RequireAny>
Require env noauth
Require env REDIRECT_noauth
Require valid-user
</RequireAny>
重新编写引擎打开
重写基/
重写规则^index\.html$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-L
重写规则/index.html[L]
AuthType Basic
AuthName“受限内容”
AuthUserFile/path/to/.htpasswd
SetEnvIf请求\u URI/openaccess noauth=1
需要env noauth
需要环境重定向\u noauth
需要有效用户