Forum Moderators: coopster
I am compressing the .htm files served from a website using these lines in my (Apache) htaccess:
AddHandler compress .htmThe compress.php file is simple (described here [ideamarketers.com]):
Action compress /php/compress.php
<?php
ob_start("ob_gzhandler");
$file = $_SERVER["PATH_TRANSLATED"];
readfile($file);
?> Before I implemented this php compression, I had the server parse .htm files as php using
AddType application/x-httpd-php .htmin htaccess. But now that the Handler is functioning (and it works great), embedded php in my .htm files is no longer executed. It seems the server may be parsing the files as php after the Handler does the compression. One solution might be to force the server to do the compression last, and parse the .htm files as php first. (I am looking into how to get Apache to do this.) But here's a thought:
Can I get the server to parse the .htm file as php from within the compress.php file, which the Handler uses?
Thanks
Dave Higgins
PS. Server: Apache/1.3.22 (Unix) PHP/4.3.4 mod_perl/1.26
I am using the zlib module for compression because mod_gzip is not installed.
include() instead of readfile(). With
readfile(), the <?php ...whatever...?> is simply displayed as text in the page source from the browser. include(), the embedded php completely disappears! The php code is not being executed (part of the php code inserts a comment back into the html saying, in effect, "everything worked ok"). So it seems that
include() doesn't do the job. (Unless there's other code to modify what include() does?) Any other ideas?
Thanks
Dave Higgins
I now have this in my .htaccess, instead of the AddHandler and Action lines:
php_value auto_prepend_file "/usr/home/dmh/WWW/mri/php/compress.php"
And the compress.php file is just
<?php
ob_start("ob_gzhandler");
?> I think that now, if the server parses anything as php, it simply adds this line to the start of the file before it does the parsing. The compression works, anyhow, and my.htm files are parsed as php again.
Dave Higgins