自定义登录通过HTML / PHP的htaccess [英] Custom Login with htaccess through HTML/PHP
问题描述
我工作的一个网站是保护与htaccess的目录。我想创建,而不是依赖于浏览器的默认定制的登录页面。任何人有任何这方面的经验吗?
I'm working on a site with a directory that is protected with htaccess. I'd like to create a custom login page instead of relying on the browser default. Anyone have any experience with this?
我想通过一个HTML表单进行连接。有人认为这可能吗?
I want to connect via a HTML form. Anyone think is it possible?
感谢。
推荐答案
是的,它是可能的,但你不应该使用htaccess的摘要式身份验证,就必须实现在HTML和放大器的自定义登录表单; PHP。
Yes it's possible but you shouldn't use the htaccess digest authentication, you have to implement a custom Login Form in HTML & PHP.
您可以实现这样的事情在PHP和放大器; htaccess的
You can implement something like this in PHP & htaccess
管理/ htaccess的:
admin/.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:
admin/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
}
您可以访问目录中的文件是这样
you can access directory files like this
check_auth.php?file=filename
这篇关于自定义登录通过HTML / PHP的htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!