By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

Adding support for PHP in HTML files with htaccess

How to add support for PHP scripting inside your HTML files.

Edited: 2015-12-04 12:29

If you for some reason can't use .php, or if you got a lot of static HTML files that you would like to enable PHP scripting for, then you should consider adding the .html file extension to be handled by PHP.

It is however recommended that you do not include file extensions in the URL, with the exception of image, sound, and video files. I.e. .mp3, .png, .mpeg.

See also: Friendly URLs

Add support for PHP in .html files

To add support for PHP scripting in your .html files, you can use the below .htaccess code, which will automatically add the listed files to be handled by PHP.

AddType application/x-httpd-php .htm .html

Normally your server would already handle the .php extension with PHP, so there should be no need to list it again.

Go to last Tutorial: Blocking IPs with Htaccess