我正在我的网站上使用网址重写,我想通过.htpasswd文件添加身份验证到我的一个目录。
我的网站就是这样建的
/home/website/
/home/website/protected/
/home/website/protected/.htaccess
/home/website/protected/.htpasswd
/home/website/protected/admin.php
/home/website/.htaccess
/home/website/index.php
/home/website/index_protected.php在/home/website/目录中,我得到了一个.htaccess文件:
RewriteRule ^directory([0-9]+)/protected/([a-z0-9-_]+).php /home/website/protected/admin.php?d=$1&p=$2 [QSA]使用url,如
http//website/directory1/protected/test.php 你会打电话给
/home/website/1/protected/admin.php?d=1&p=test在.htaccess上,我从/protected/目录获得:
AuthName "Page d'administration protégée"
AuthType Basic
AuthUserFile "/home/website/protected/.htpasswd"
Require valid-user在.htpasswd上的/protected/目录中,我得到了:
admin:crypted_password但我的问题是,当我调用
http//website/directory1/protected/test.php我从来没有得到身份验证窗口,有什么办法解决这个问题吗?
发布于 2012-07-04 21:45:40
您可以尝试将带有基本Auth指令的.htaccess文件放到受保护的目录中。
发布于 2012-07-04 21:52:29
当服务器不使用.htaccess文件时,通常会发生这种情况。检查是否允许使用/home/website/protected/不仅仅是/home/website/中的该文件。
https://stackoverflow.com/questions/11330255
复制相似问题