阻止MIME的盗链请求
我试图阻止人们盗链到PDF和DOC文件。 通常,我会用这样的.htaccess规则来处理这个问题: RewriteEngine On RewriteBase / RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain.com/.*$ [NC] RewriteRule \.(pdf|doc)$ /home/ [R=302,L] 然而,这些文件中的许多文件通过php脚本链接,例如filedownload.php?id = 5,然后触发PDF / DOC文件的下载。 有没有办法防止通过输出文件的MIME链接到这些文件? 其他方式? 编辑 – 添加此源来显示如何调用文件: header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); header("Content-Type: $ctype"); header("Content-Disposition: attachment; filename=\"".basename($fn)."\";" ); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".$fs); echo $upload["file_contents"]; exit();