我正在开发一个网站,该网站的目录受 htaccess 保护。我想创建一个自定义登录页面,而不是依赖浏览器默认页面。有人对此有经验吗?
我想通过 HTML 表单进行连接。有人觉得可能吗?
Thanks.
是的,这是可能的,但您不应该使用 htaccess 摘要身份验证,您必须在 HTML 和 PHP 中实现自定义登录表单。
你可以在 PHP 和 htaccess 中实现类似的东西
管理/.htaccess:
RewriteCond %{REQUEST_FILENAME} !check_auth.php
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .* check_auth.php?file=$0 [QSA,L] # pass everything thru php
管理/check_auth.php:
$file = $_GET['file'];
if($_SESSION['user_authenticated']) {
// please mind you need to add extra security checks here (see comments below)
readfile($file); // if it's php include it. you may need to extend this code
}else{
// bad auth error
}
你可以像这样访问目录文件
check_auth.php?file=filename
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)