httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From S.Marsh...@open.ac.uk
Subject mod-rewrite: rewrite rules and T=/type=
Date Wed, 19 Jun 2002 09:52:48 GMT
Hello. I am using Apache 1.3.23 on a pair.com server (others have tried on
different hosts too), and we are having problems with a RewriteRule. The
summary is that we can't get the type= / T= parameter to do anything.

Here is a simple .htaccess demonstrating the problem:

RewriteEngine on
RewriteRule frog lizard [T=image/gif]

As far as I can figure out (and I know *nothing* about rewrite rules before
yesterday, but I did look through the docs and ask for help from people who
knew more), this *should* mean that when I request the URL 'frog', I am in
fact sent the content from the file 'lizard', and with the MIME type
image/gif.

However, though requesting 'frog' does correctly give me the content from
the file 'lizard' (i.e. the basic part of the rewrite rule works), the
server still assigns its default MIME type (text/plain). If I used another
extension, like say lizard.html, then the MIME type would be the server's
type for that extension (text/html). In other words, the T= parameter to the
RewriteRule appears to be completely ignored.

I have tried:
  using type= instead of T=
  appending a ,L to the rule

So um... does anybody know what we are doing wrong? Or is it a bug in
RewriteRules and they don't actually support T= at all? Or we misunderstood
T= and it isn't intended to do anything useful in this regard?


If you are wondering, the reason for this is that we are trying to figure
out a way to make Apache transparently serve XHTML files as text/html for
legacy browsers (including IE) and as the correct MIME type
application/xhtml+xml for current browsers (Mozilla) which indicate that
they can accept such files. There *are* other ways to do this but they
involve either using additional applications like PHP or CGI scripts, or
unpleasant hacks like creating two identical files .xhtml and .html and
using the content negotiation stuff. A three-line .htaccess which would
achieve this absolutely transparently would be ideal, and we came up with:

RewriteEngine on
RewriteCond %{HTTP_ACCEPT} application\/xhtml\+xml
RewriteRule ^(.+)\.html $1.html [T=application/xhtml+xml]

All of this works *except* the vital part that actually changes the MIME
type, which is a bit disappointing. :)

--sam

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message