1. 修改 /etc/apache2/sites-enabled/whycan.cn.conf, 添加
RewriteRule ^/(.*)\.7z /dl.php
2. 添加 dl.php 文件
<html>
<head>
<meta charset="utf-8" >
</head>
<body>
<?php
$dlfilename = "." . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
if (file_exists($dlfilename)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($dlfilename).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($dlfilename));
readfile($dlfilename);
exit;
}
else
{
printf("no this file: %s <br />\n", $dlfilename);
printf("骗子!根本没有这个文件: %s <br />\n", $dlfilename);
}
?>
3. 下面测试测试:
这个OK: suniv_f1c100s_w25q128_usb_adb_emwin_20190901.7z
这个假链接: suniv_f1c100s_w25q128_usb_adb_emwin_20190901X.7z
感谢 @Beta_vulgaris
离线