Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some mp3 files which are named "my-audio.mp3" but now the client wants the visitor to be able to download and save these files to their desktop. He doesn't like the name with the hyphen and wants them renamed to "MyAudio.mp3". Other than putting the renamed files into their own 'download' folder, how can I make this work on Apache?

share|improve this question
up vote 1 down vote accepted

You can do this in PHP like so:

// We set the file type here
header('Content-Type: audio/mpeg');

// un-comment this line if you want to enforce download and comment the line above
// Content-Type "application/force-download"

// It will be called MyAudio.mp3
header('Content-Disposition: attachment; filename="MyAudio.mp3"');

// The MP3 Source
share|improve this answer
This is what I was thinking I'd have to do, and have no problems with that, but was also wondering if Apache had any automagic to do the same thing. – Rob Mar 4 '13 at 14:32
Simple things such as the renaming is always done on the page and not within the web hosting software. There is no Apache Module for doing this as far as I know. – Simon Hayter Mar 4 '13 at 14:43

Apache can be configured to follow symbolic links. I tested creating a symbolic link for the desired name to the old name. On the command line I did:

ln -s My-Music.mp3 MyMusic.mp3

After which, Apache was happy to serve up the file at either http://localhost/My-Music.mp3 or http://localhost/MyMusic.mp3

To make it work you just have to have the correct option turned on in your .htaccess file:

Options +FollowSymLinks
share|improve this answer
But the same audio file must play online or be downloaded depending on which link is clicked. In our case, there is a .../download/MyMusic.mp3 URL. – Rob Mar 4 '13 at 17:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.