htaccess で保護されたディレクトリを持つサイトで作業しています。ブラウザのデフォルトに依存するのではなく、カスタム ログイン ページを作成したいと考えています。誰でもこれを経験したことがありますか?
HTMLフォーム経由で接続したい。誰でも可能だと思いますか?
ありがとう。
はい、可能ですが、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