Help - Forcing a mp3 files to download in a browser via htaccess

Hello, I have files directory in a self-hosted wordpress site
I am unable to force download mp3 files
all they do is open and play in all browsers,
I need to know how to download by clicking on link

I have placed below code in .htaccess

<FilesMatch “.(?i:mp3)$”>
ForceType application/octet-stream
Header set Content-Disposition attachment

anyone with a solution, please?

1 Like

Welcome @samthingwise Happy you are here

  1. Set MIME type for binary file with application/octet-stream
  2. Set header on how to process the payload received i.e. download locally as an attachment
<FilesMatch "\.(mp3)$">
   ForceType application/octet-stream
   Header set Content-Disposition attachment
</FilesMatch>

In future, post questions that are not relevent to CyberPanel on developer communities such as StackOverflow or just use a search engine

i did the same thins, and i stll have the problem…

<FilesMatch “.(mp3)$”>
ForceType application/octet-stream
Header set Content-Disposition attachment

in my htaccess isnt working!

josephgodwinke hi, please i have searched all over the internet for a way to force downloads, and it doesn’t work, even the method you posted does not work either, please i need assistance

josephgodwinke Hi sir, the code you provided doesn’t work to force downloads of mp3 files, i also tried other methods i found on google doesn’t work either. please help

Set content-dispostion in header of the page you are trying to download the file

Please sir, how is this done?

I am new to cyberpanel and I am just learning how to tweak some settings, the tutorials on this topic is not found anywhere, I understand I cannot achieve this by setting content-disposition via htaccess, please is this ‘set content-disposition’ done on my cyberpanel server dashboard or how exactly can i get it done

I will really appreciate a layman’s explanation, i am so frustrated. been trying to get this done for months now