Forum Moderators: phranque

Message Too Old, No Replies

addtype vs addhandler

.htm no longer parsed as php despite addtype

         

dhiggerdhigger

4:11 pm on Mar 31, 2004 (gmt 0)

10+ Year Member



I had these lines (among others) in my .htaccess:

AddType application/x-httpd-php .htm

Options +Includes +ExecCGI
XBitHack on
<IfModule mod_php4.c>
php_value auto_prepend_file "/usr/home/dmh/WWW/mri/php/pausebots/pausebots.php"
</IfModule>

Embedded PHP in my html files was executed and all was well. I then tried to make use of the zlib php module so that all my .htm pages were compressed if the client could handle it by adding these line:

AddHandler compress .htm
Action compress /php/compress.php

It worked! Most of my .htm pages are about one-third of their original size when they are served.

BUT...here is the problem: php within the .htm file is no longer executed. Can anyone shed any light?

Thanks
Dave Higgins

jdMorgan

5:07 pm on Mar 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, I'll hazard a guess that your .htm files *are* still being parsed for php... But since they are now compressed, the parser cannot recognize the php code anymore.

Compression and dynamically-generated pages are not mutually-exclusive, but they are certainly "contradictory" approaches.

Jim

dhiggerdhigger

8:29 am on Apr 1, 2004 (gmt 0)

10+ Year Member



Thanks for your reply JD.

So I assume the compression (via that handler) is occurring before the server parses the htm files for php.

Is there any way of making the server parse the files first before the handler takes effect?

Thanks
Dave Higgins

PS
What if the "parse .htm as php" instruction to the server could be made within my compress.php file, before compression is started? Is this possible?
Should I take that question to a PHP forum?
:)

dhiggerdhigger

4:47 pm on Apr 1, 2004 (gmt 0)

10+ Year Member



I have a solution. It was in my first post! I am using
php_value auto_prepend_file "/usr/home/dmh/WWW/mri/php/compress.php"

The compress.php simply contains
ob_start("ob_gzhandler");
.

The AddHandler removed the effect of the first AddType line, so it was no use. By getting the server to add the php to any files it parses as php (I think it only does this to parsed files), it then (of course) parses them, and all my php is executed.

Dave Higgins