Forum

Executing embedded PHP in .html files?

Rodney Hester
21 January 2011, 14:30
Hiawatha version: 5.4
Operating System: Tomato firmware (Linux 2.6)

For embedding PHP in content with a .html extension (where the extension can't be easily changed without causing large-scale breakage), a common trick used on Apache is something like the following (on a per-site/per-directory basis):

AddType application/x-httpd-php .html

Is something similar possible with Hiawatha? I've tried:

- The sledgehammer approach, adding "application/x-httpd-php html" to mimetype.conf. No change in output from Hiawatha (still just getting the raw HTML without the PHP being parsed).

- Adding "CGIhandler = /usr/bin/php-cgi:html" to the VirtualHost stanza in hiawatha.conf. This produced an (expected) syntax error.

Any other approaches I can try _without_ having to rename or modify hundreds of .html files?

Rodney
Hugo Leisink
22 January 2011, 10:35
You could specify a seperate FastCGI PHP daemon and add html to the extension setting. Use this new FastCGI server only for your .html PHP website.

FastCGIserver {
FastCGIid = PHP5
ConnectTo = <FastCGI binding>
Extension = php
}

FastCGIserver {
FastCGIid = PHP5_HTML
ConnectTo = <FastCGI binding>
Extension = php, html
}


Use the last FastCGI definition for the .html PHP website, and the first for all other PHP websites.


What kind of webapplication are you talking about btw? No offense, but it sounds like real bad webdesign if the .html extension is used for PHP.
Rodney Hester
24 January 2011, 16:21
I'm assuming there's no way to achieve this without FastCGI, correct?

No offense taken - I'm migrating from hlscript to nanoblogger and trying to maintain a lot of the functionality I developed on the former. The notion of dynamic-without-really-being-dynamic code is a mess.

Rodney
Hugo Leisink
24 January 2011, 18:24
If you want .html files to be handled like PHP files in only one virtual host, then the FastCGI solution is your only option.
This topic has been closed.