我不想使用apache或PHP版本来使用此AuthType Basic。
<Directory "/src/Members.jpg">
AuthType Basic
AuthName darkness
AuthUserFile /usr/www/
AuthGroupFile /usr/www/
require valid-user
</Directory>
然后弹出登录框出现......。需要身份验证!
我只想将它们引导到php页面,并通过PHP处理所有auth的东西 apache重写mod指令可以做到吗?
答案 0 :(得分:0)
Readfile是您需要的功能,您可以执行以下操作:
<?php
$file = 'thefile.zip';
if ( permissionCheck() === true) {
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
exit;
} else {
echo 'You do not have permission to view this file';
}
然后,您可以将文件保留在公共webroot之外,这样就无法直接访问这些文件,只是在想要公开它们时用PHP读取它们。