I have the following mod_rewrite
directive in my lighttpd config file:
url.rewrite-once = (
"foo.*$" => "static/foo.pdf",
)
I'd like to hand out URLs like this: http://<server>/foo/r=ca2b912
(or similar), such that I can track the origin of the link in the http access log.
When I enter http://<server>/foo/r=131ab42
, however, the "save-as" file dialog is shown and is proposing to name the file r=131ab42
(at least when using firefox). I'd like to have it propose foo.pdf
as file name to save. This should work independent of the tool accessing the URL (ie. wget, IE, etc should all save the file as foo.pdf
).
How can I achieve that? I've noticed that firefox corrects the file name when reloading the URL.
Please note: this is the first time I want to use a rewrite rule. I have tried to find the answer myself, but have not succeeded.
rewrite is a server internal operation; the user doesn't see the result (unless you expose it manually in some way).
You could try the Content-Disposition header; but the best way is to fix your URLs (i.e. have
.../foo.pdf
from the beginning). You could use redirect rules for the migration.You just need to prefix your
r=ca92b32
string with a?
(ie:http://<server>/foo/?r=ca93b32
)The string will be considered as a parameter instead of a filename and won't be treated as a filename.