download.php如何知道“标题”的位置?

I'm not really sure how to phrase this question. I'm working on a website someone else built and I need to add a new link to a secure audio downloads page. I figured I could just copy and paste the code for a link and put in the right file paths, but that didn't work and I don't know why.

This is code for the download link:

</p><p>Download <strong><a href="http://www.*website*.com/cds/downloads/old_file/<? echo $key; ?>/">old_display_title</a></strong><br />

Currently, the download links echo a hashed $key at the end of the file path to keep the real file secure:

$key = substr(uniqid(md5(stuff to hash), 0, 12); 

I copied one of the links that works and simply replaced old_file and old_display_title with the new filename, "audio". The actual file I want to download is audio-4jf30m03.mp3, but the real filename is not referenced just yet for security.

Just with those changes, it doesn't download, rather it only loads a 404 saying that /downloads/audio/$key (the value, not actually "$key") doesn't exist...

Normally, when one clicks the link it opens a new tab for a second then still initiates the download like normal, I suspect because of this part of the download.php file in the /downloads folder:

$title = trim(eregi_replace("[^a-z]", '', $_GET['title']));

$realfilename = $title . "-4jf30m03.mp3";
$fakefilename = $title . ".mp3";

Then $fakefilename is used in a header(content.disposition: attachment; filename= ' ') so the user doesn't get the real file name and then$realfilename is what is actually downloaded.

I think $title is where something goes wrong, but I really don't know. I just can't understand why one file works and another doesn't when the code is the same and they're both saved in exactly the same place and exactly the same way.

Somehow, download.php knows when to take the $key and associate it with real file, and it does it for the ones currently there and not the one I added.

PS. I'm still pretty new to all this. Sorry if the question is long, I just wanted to be thorough.

Got this from the comment of @Jakumi .

There is a url rewrite magic happening. In the .htaccess file there is a RewriteRule taking the /filename/$key and turning it into /download.php?id=$2&title=$1.

Simply adding "audio" in the appropriate place solved it, allowing the rewrite to send that as a title to download.php.