我已经使用htaccess文件添加了htpasswd保护进行身份验证,现在我想绕过两个url访问index.php文件的www.website.com
和www.website.com/index.php
的身份验证。通过使用下面的htaccess文件,我已经允许index.php,我可以绕过www.website.com/index.php
网址而不是www.website.com
我的htaccess文件是:
# set an environtment variable "noauth" if the request starts with "/callbacks/"
SetEnvIf Request_URI ^/index.php noauth=1
AuthType Basic
AuthName "RESTRICTED"
#AuthName "Restricted Area"
AuthUserFile "/path/to/.htpasswd"
require valid-user
Options -Indexes
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+)$ /file.php?show=all&name=$1 [L]
# Here is where we allow/deny
Order Deny,Allow
Satisfy any
Deny from all
Require valid-user
Allow from env=noauth
答案 0 :(得分:2)
我相信第二个参数只使用常规正则表达式。也许你可以让index.php可选。
SetEnvIf Request_URI "^/(index\.php)?$" noauth=1
尚未测试过。