Rumah > Artikel > pembangunan bahagian belakang > apache中对非站点索引的访问限制
apache中对非站点目录的访问限制
apache设置中有一段
Alias /test "/var/www/web2/test"
Options FollowSymLinks Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
如果此时 /var/www/web2/test 目录中有一个php下载的页面
down.php大概是这样:
$filename=$_GET["file"];<br /> <br /> ob_end_clean();<br /> header("Expires: 0");<br /> if(!$file = @fopen($filename,'r')){<br /> echo 'read error';<br /> exit();<br /> }<br /> <br /> flock($file,LOCK_SH);<br /> $filesize=filesize($filename);<br /> <br /> Header("Content-type: application/octet-stream");<br /> Header("Accept-Ranges: bytes");<br /> Header("Accept-Length: ".$filesize);<br /> Header("Content-Disposition: attachment; filename=" . $file_name);<br /> if($filesize>0)<br /> {<br /> echo fread($file,$filesize);<br /> }<br /> fclose($file);<br /> ob_get_contents();<br /> ob_end_clean();<br /> exit;