我已经使用 htaccess 文件添加了 htpasswd 保护进行身份验证,现在我想绕过身份验证www.website.com
and www.website.com/index.php
其中两个 url 都在访问 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
我相信第二个参数只使用常规正则表达式。也许你可以将index.php设为可选。
SetEnvIf Request_URI "^/(index\.php)?$" noauth=1
没有测试过。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)