使用htaccess在页面加载时下载特定文件


Download specific file on page loading using htaccess

我正试图让我的.htaccess文件强制下载网站根目录中包含的特定*.zip文件。

基本上,在加载我的页面时,用户会自动下载我的*.zip文件,甚至不会看到目录列表。

这是我的.htaccess文件:

### MAIN DEFAULTS
Options +ExecCGI -Indexes
DirectoryIndex file.zip
DefaultLanguage en-US
AddDefaultCharset UTF-8
ServerSignature Off
### FORCE FILE TO DOWNLOAD INSTEAD OF APPEAR IN BROWSER
AddType application/octet-stream .zip
AddType application/zip .zip 

我可以下载该文件,但后者没有扩展名,名为download

我该怎么解决这个问题?

感谢

-RJ

将此行添加到.htaccess文件的末尾:

Header set Content-disposition "attachment; filename=file.zip;"