Fake filname.txt for MSIE

Using mod_rewrite to handle various content issues

Postby moj » Wed Nov 21, 2001 12:59 am

MSIE has a habit of letting file name extension (.txt) take precedence before the server submitted content type (application/octet-stream)). This means that files ending with .txt always will be displayed. Another bug in MSIE is that it is extremely slow to display large text files (> 1 meg).

Is it possible to use mod_rewrite to fake a different filename (filename.dat) even if the original file still is filename.txt?
Posts: 1
Joined: Tue Nov 20, 2001 4:00 pm

Postby Brett » Sun Nov 25, 2001 8:19 pm

Sure, just include something like the following in your .htaccess file:
RewriteEngine on
RewriteRule ^filename.dat$ filename.txt

Or, more generally:
RewriteEngine on
RewriteRule ^(.*).dat$ $1.txt
Posts: 82
Joined: Tue Jul 10, 2001 4:00 pm
Location: yohost.com

Postby Peutch » Sun Nov 28, 2004 2:50 pm

RewriteRule ^filename.dat$ filename.txt

This is no solution. Because when someone calls for filename.txt, she will still get the filename.txt and the pb with MSIE is unsolved.

You can store your file as filename.dat and call it as filename.txt only if the user is not using MSIE :
Code: Select all
RewriteCond %{HTTP_USER_AGENT} msie
RewriteRule ^filename.dat$ filename.txt

Not so sure about the "msie" part but you can tweak and find out.[/code]
Posts: 3
Joined: Sun Nov 28, 2004 2:44 pm

Return to Content

Who is online

Users browsing this forum: No registered users and 1 guest