【发布时间】:2020-06-19 21:08:31
【问题描述】:
我有以下带有基本身份验证和 URL 重写的 .htaccess 文件。我需要禁用特定路径的基本身份验证(例如,'/openaccess'),但重写首先发生,所以我无法使用 SetEnvIf 禁用身份验证。我找到的最接近的东西是this answer,但它在 Apache 2.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
【问题讨论】:
标签: apache .htaccess mod-rewrite setenvif