NYCPHP Meetup

NYPHP.org

[nycphp-talk] Parse HTML Files as PHP

tedd tedd at sperling.com
Sat Feb 21 10:37:41 EST 2009


At 4:34 PM -0500 2/20/09, Peter Sawczynec wrote:
>I want to get my *. htm and *.html files to be parsed as PHP files.
>With shared hosting I don't have access to Apache conf, but I can put
>.htaccess files
>in my dirs. So I am planning to add this line:
>
>AddHandler application/x-httpd-php .html .htm
>
>Š in the .htaccess file.
>
>Anyone have any comment on this strategy pro or con?
>Has anyone done this and was satisfied with the results?
>
>Warmest regards,
>
>Peter Sawczynec

Peter:

I don't know how to judge if it's a good idea, or 
not -- but I do it. My .htaccess file is a bit 
different from yours, namely:

# handler for phpsuexec. -- this makes these prefixes considered for php
<FilesMatch "\.(htm|html|css|tpl)$">
  SetHandler application/x-httpd-php
</FilesMatch>

Note that I also have css in there so I can embed 
php code in css -- that's neat.

The only problem I have run into that some 
browsers, like FireFox require this --

<?php header('Content-Type: text/css; charset=UTF-8'); ?>

-- to be the first line in my non-php files. But 
that hasn't been a big problem for me.

HTH's

tedd

-- 
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com



More information about the talk mailing list