我将代码从一台服务器移到了另一台服务器。在网站上,我正在为登录用户下载。当我输入检查是否已登录的文件时,它显示错误500(内部服务器错误)。下面我给出代码.htaccess和download.php
.htaccess:
Options -Indexes
<files .htaccess>
order allow,deny deny from all
</files>
<FilesMatch "\.(htaccess|htpasswd|ini|phps|fla|psd|log|sh|pdf|mp4)$">
Order Allow,Deny Deny from all
</FilesMatch>
RewriteEngine on
RewriteRule ^(.*).pdf$ http://example.com [R=301,L]
Download.php:
<?php ob_start();?>
<?php session_start();?>
<?php
if (!isset($_SESSION['login_user'])) {
header("location: http://example.com");
exit;
}
if ($_SESSION['nazwau'] == "ALG2") {
$file = './pdf/test.pdf';
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
} else {
header("location: http://example.com/");
exit;
}
?>