You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Brian Candler <B....@pobox.com> on 2005/07/28 13:42:32 UTC

[users@httpd] mod_rewrite setting handler

Question: is it possible to set the MIME-type and the handler separately in
mod_rewrite?

(1) If I do

RewriteRule \.shtml?$  -  [T=server-parsed,L]

then the page is parsed, but the wrong MIME type is sent to the client
("server-parsed" instead of "text/html")

(2) If I do

AddHandler server-parsed .shtml .shtm
RewriteRule \.shtml?$  -  [T=text/html,L]

then I get the right MIME type, but no server parsing.

(3) I can make it work like this:

AddType text/html .shtml .shtm
AddHandler server-parsed .shtml .shtm
RewriteRule \.shtml?$  -  [L]

but that's a bit limited flexibility-wise (i.e. it only applies for files
ending .shtm or .shtml). Is there a better way of doing this?

Obviously, these rewrites are cut-down examples. If *all* I wanted to do was
match .shtm or .shtml and set the MIME-type and handler, the rewrite
wouldn't be needed in (3).

Cheers,

Brian.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_rewrite setting handler

Posted by André Malo <nd...@perlig.de>.
* Brian Candler wrote:

> To answer my own question, by looking at the source: there's a "magic"
> MIME type for this case.
>
>     [T=text/x-server-parsed-html]
>
> will use the server-parsed handler, but set the return MIME type to
> text/html.

Further, in 2.1/2.2 it will be possible to explicitly set the handler with 
mod_rewrite.

nd
-- 
Treat your password like your toothbrush. Don't let anybody else
use it, and get a new one every six months.  -- Clifford Stoll

                                    (found in ssl_engine_pphrase.c)

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_rewrite setting handler

Posted by Brian Candler <B....@pobox.com>.
On Thu, Jul 28, 2005 at 12:42:32PM +0100, Brian Candler wrote:
> Question: is it possible to set the MIME-type and the handler separately in
> mod_rewrite?
> 
> (1) If I do
> 
> RewriteRule \.shtml?$  -  [T=server-parsed,L]
> 
> then the page is parsed, but the wrong MIME type is sent to the client
> ("server-parsed" instead of "text/html")

To answer my own question, by looking at the source: there's a "magic" MIME
type for this case.

    [T=text/x-server-parsed-html]

will use the server-parsed handler, but set the return MIME type to
text/html.

B.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org