I currently have an html page that uses SSI. I now need to add some php code to that html page:
<?php
session_start();
$_SESSION["animal"] = "dog";
?>
<!DOCTYPE html>
<html>
I can successfully implement either the SSI or the php, but not both. I believe the problem is here, in my httpd.conf file:
AddType text/html .html
AddOutputFilter INCLUDES .html
AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .php .html
LoadModule php5_module "C:/php5/php5apache2_4.dll"
PHPIniDir "c:/php5"
</IfModule>
I have 2 different lines for AddType, and which ever AddType is listed second, is the one that works. Is there a way to get both AddType's working at the same time?
Thanks!
Use FilesMatch
and SetHandler
and put this in .htaccess
instead of httpd.conf
:
# Enable server side includes
Options +Includes
# Handle files ending in .php, .shtml, and .html using the PHP interpreter:
<FilesMatch "\.(php|shtml|html)$">
SetHandler application/x-httpd-php
</FilesMatch>
# Filter .php, .shtml and .html files through mod_include first
AddOutputFilter INCLUDES .php .shtml .html
And test both in the same page:
<!DOCTYPE html>
<head>
<title>PHP/SSI Test Page</title>
</head>
<body>
<!--#echo var="DATE_LOCAL" -->
<? echo "Last Updated: ".date("F jS Y",
getlastmod() ); ?>
</body>
</html>
References