Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 禁用重写路径的htaccess身份验证_Apache_.htaccess_Mod Rewrite_Setenvif - Fatal编程技术网

Apache 禁用重写路径的htaccess身份验证

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

我有以下带有基本身份验证和URL重写的.htaccess文件。我需要禁用特定路径的基本身份验证(例如,“/openaccess”),但重写首先发生,因此我无法使用SetEnvIf禁用身份验证。我发现的最接近的东西是,但它在Apache2.4.34上对我不起作用

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
需要有效用户