[thelist] Apache2 + inline PHP in .html file - solved

Kevin Martin evolt at brasscannon.net
Thu Oct 9 00:08:46 CDT 2003

As mentioned here a month or two ago, we ran into a problem when we first 
convered to Apache 2 -- trying to include PHP code in an otherwise plain .html 
page (one with a .html filename) stopped working.  Could force it, sort of,
but ANY error in a page would kill the child process.  Another symptom was 
that .htaccess files would not work at all.  In fact, I had to turn off 
mod_auth or Apache would not start!
Well, it turns out to be stupidly simple to fix.  The online PHP manual has a 
recent comment from a guy who discovered that while the new SetOutputFilter
syntax in /etc/httpd/conf.d/php.conf works for .htm files, you need the older 
"AddType" syntax for .html files:

# This is in /etc/httpd/conf.d/php.conf 
# Per http://www.php.net/manual/en/install.apache2.php,
# you have to handle .html and .htm separately:

AddType application/x-httpd-php  .html
<Files *.htm>
    SetOutputFilter PHP
    SetInputFilter PHP
    LimitRequestBody 524288
# Duh.

I can be smarter.  Can you be nicer?  No, wait, THAT's not right....

More information about the thelist mailing list