I have some mp3 files in different directories other than root directory.
When users click on the links to mp3, instead of downloading it starts streaming in most browsers (mostly in mobile browsers).
I have tried adding the below code in the .htaccess, but no luck
<FilesMatch "\.(?i:mp3)$">
ForceType application/octet-stream
Header set Content-Disposition attachment
</FilesMatch>
My server is build in apache and nginxcp (nginx admin). Can anyone help me out?
EDIT: Below is the edited file for my domain vhost file. But after i rebuild host and restart nginx, the file change to its original one and the code "location ~ .mp3$ { add_header Content-Disposition attachment; }" becomes disappears.
server {
error_log /var/log/nginx/vhost-error_log warn;
listen 198.xxx.xx.xxx:80;
listen [::]:80;
server_name dl.xxxx.com www.dl.xxxx.com;
access_log /usr/local/apache/domlogs/dl.xxxx.com-bytes_log bytes_log;
access_log /usr/local/apache/domlogs/dl.xxxx.com combined;
root /home/xxxx/public_html/download;
#location / {
location ~*.*\.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|html|htm|txt|js|css|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso)$ {
expires 1M;
try_files $uri @backend;
}
location / {
error_page 405 = @backend;
add_header X-Cache "HIT from Backend";
proxy_pass 198.xxx.xx.xxx:8081;
include proxy.inc;
include microcache.inc;
}
location @backend {
internal;
proxy_pass http://198.xxx.xx.xxx:8081;
include proxy.inc;
include microcache.inc;
}
location ~ .*\.(php|jsp|cgi|pl|py)?$ {
proxy_pass http://198.xxx.xx.xxx:8081;
include proxy.inc;
include microcache.inc;
}
location ~ /\.ht {
deny all;
}
location ~ \.mp3$ { add_header Content-Disposition attachment; }
}