Running php code in html files - addhandler ?
I have just setup a 512 linode account with LAMP stack for Ubntu 10.04 LTS and followed guides by linode to setup sites.
Everything is working fine but I want to run PHP code under html files for that I have tried adding
AddHandler application/x-httpd-php5 .php .html .htm
in .htaccess file and sites_available/virtualhost file as well but its not working, view source html file shows php code in it and not being parsed at server.
please help!
5 Replies
AddType application/x-httpd-php .html .htm
If that doesn't work, you could instead try the following in .htaccess (pattern found in /etc/apache2/mods-available/php5.conf):
<filesmatch "\.html?$"="">SetHandler application/x-httpd-php</filesmatch>
Either of these versions will match both .htm and .html file extensions.
But can you guide me about how to add this line in httpd.conf or php5.conf (dont not exists), so I dont have to add this line in every .htaccess?
SetEnv PHPRC /location/todir/containing/phpinifile
.htaccess for php as cgi ^
AddHandler php-cgi .php .htm
Action php-cgi /cgi-bin/php5.cgi
Shell wrapper for custom php.ini ^
!/bin/sh
export PHPFCGICHILDREN=3
exec php5.cgi -c /abs/php5/php.ini
That's a little guide of what you have to use your htaccess
Regards