Mod_rewrite vs symlink: browser not fooled
I have a file foo.bar.1 on my server, and when I try to access it from a browser (firefox), I get a popup that says, "You decided to open foo.bar.1, which is: 1 file ... What Firefox should do with this file ... ". If I create a symbolic link to it, foo.dat, I can access it just fine; displaying the content in the browser as I expect.
My problem is that I don't want to create symlinks for all of these files, I want to use the mod_rewrite rule like
RewriteRule ^([^/]+)\.dat$ $1.bar.1
But it doesn't act like a symbolic link. It gives the same popup (although, oddly enough, it now says, "You decided to open foo.dat, which is: DAT file ...".
How can I make the rewrite rule such that the browser is tricked into treating it as a regular .dat file like a symbolic link does?
a source to share
If you have mod_mime installed, you can do:
AddType text/plain .1
Untested, but it should display the file instead of downloading
See http://httpd.apache.org/docs/2.0/mod/mod_mime.html#addtype for AddType documentation
a source to share
Refer to the argument [T]
to the directive RewriteRule
:
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule
When you create a symbolic link, Apache thinks it is serving a file .dat
, while when using mod_rewrite, Apache still thinks it is serving a file .1
. This appears in the Content-type header that is served to the browser.
a source to share