绕过带有index.php的url的htpasswd身份验证,没有它

时间:2015-03-26 12:58:06

标签: php apache .htaccess httpd.conf

我已经使用htaccess文件添加了htpasswd保护进行身份验证,现在我想绕过两个url访问index.php文件的www.website.comwww.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

1 个答案:

答案 0 :(得分:2)

我相信第二个参数只使用常规正则表达式。也许你可以让index.php可选。

 SetEnvIf Request_URI "^/(index\.php)?$" noauth=1

尚未测试过。