php - 使用 index.php 和不使用它绕过 url 的 htpasswd 身份验证

标签 php apache .htaccess httpd.conf

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

还没有测试过。

关于php - 使用 index.php 和不使用它绕过 url 的 htpasswd 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29279039/

相关文章:

wordpress页面内的PHP区域

javascript - 如何根据 onclick 函数获取两个输入字段值

php - 如何在 PHP 中找到一年中的当前日期?

linux - 如何在 solr 中配置 IndexBasedSpellChecker?

php - 加载 Magento 页面时出现奇怪的错误

linux - Apache httpd 与 Tomcat 7 : port 80 vs. 端口 8080

html - 如何使用如下所示的 htaccess 文件创建无扩展名 url?

php - 选定的自动完成值未显示在输入框中

wordpress - 查询字符串断页

.htaccess - 如何在htaccess中将新域重定向到旧域的子页面