Forum Moderators: coopster
Requests to your server for URL 'A' can be intercepted by Mod_Rewrite and a suitable rewrite will pull the content from file 'B'. These rules can be crafted to cover just one file at a time, or with a suitable regular expression can deal with all URLs of a certain type/pattern. Note this is a rewrite, not a redirect.
The file extension part of the filename of the file on the server is used to trigger the action of adding a suitable MIME type as the content is served.
I want to be able to click a link
<a href="download.php?file=random.htm">click</a>
and it pop up a window asking you to download songname.mp3 or files.zip. is there a preferred way to do this?
Here is another example. I am using a third party flash uploader which has an option to change the file name on the upload. it makes it some arbitrary file name and I think with no extension name at all. how are you supposed to work with something like that?
yes, with Mod_Rewrite.
you're wanting the server to send "file A" when someone asks for "file B". now, you could write a script in php that finds the correct file, reads it into memory, generates the right MIME Type (http://en.wikipedia.org/wiki/MIME_type) in the header and then outputs the file contents into the page, but this would be resource intensive and, imo, a really bad idea.
the simple, clean, fast way of doing this is by using Mod_Rewrite.
> how are you supposed to work with something like that?
by finding another upload script.