使用 index.php 和不使用 url 绕过 htpasswd 身份验证
Bypass htpasswd authentication for url with index.php and without it
我已经使用 htaccess 文件添加了 htpasswd 保护进行身份验证,现在我想绕过 www.website.com
和 www.website.com/index.php
的身份验证,其中两个 url 都在访问 index.php 文件.通过使用下面的 htaccess 文件,我允许 index.php 并且我能够绕过 www.website.com/index.php
url 但不能绕过 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= [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
没有测试过。
我已经使用 htaccess 文件添加了 htpasswd 保护进行身份验证,现在我想绕过 www.website.com
和 www.website.com/index.php
的身份验证,其中两个 url 都在访问 index.php 文件.通过使用下面的 htaccess 文件,我允许 index.php 并且我能够绕过 www.website.com/index.php
url 但不能绕过 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= [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
没有测试过。