I wanted to add some php code to an existing static html page. But I noticed that the PHP content didn’t render on the browser in the first place. It would only work if I renamed the file extension from .html to .PHP.
In order to have the php content work in an HTML file extension, the following piece of configuration is required within the .htaccess file on your server. This can be created on the site’s root directory and the properties are inherited by all the sub-directories.
AddType application/x-httpd-php .html
In order to enable PHP within HTML code on a Mac,
Look for <Directory “/Library/WebServer/Documents”> and change AllowOverride None to AllowOverride All
Restart apache and you should be all set.
sudo apachectl restart