简体   繁体   English

Apache下载具有特定扩展名的文件

[英]Apache download files with specific extension

I have download directory on apache webserver. 我在apache网络服务器上有下载目录。 Files in this directory have specific extensions. 此目录中的文件具有特定的扩展名。 For example *.yyy and *.zzz. 例如* .yyy和* .zzz。 But all these files are renamed .zip or .tar.gz 但是所有这些文件都被重命名为.zip或.tar.gz

I've tested in different brawsers and havn't got any problems. 我已经在不同的浏览器中进行了测试,但没有任何问题。

But some users tell that they get source of packages, not download. 但是有些用户告诉他们,他们获得软件包的来源,而不是下载。

I've created.htaccess 我已经创建了.htaccess

AddType application/zip .zzz
AddType application/x-gzip .yyy

But when I try to download aaa.yyy in MS Internet Explorer it try to save not aaa. 但是,当我尝试在MS Internet Explorer中下载aaa.yyy时,它尝试不保存aaa。 yyy but aaa. yyy但aaa。 gz GZ

How to force browsers download files and not to change extensions? 如何强制浏览器下载文件而不更改扩展名?

<FilesMatch "\.(zzz|yyy)$">
  ForceType application/octet-stream
  Header set Content-Disposition attachment
</FilesMatch>

Force type tell browsers that you dont know file type. 强制类型告诉浏览器您不知道文件类型。 So they are not going to do any thing stupid. 所以他们不会做任何愚蠢的事情。 Second line will tell them to download this file. 第二行将告诉他们下载此文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM