Processing PHP in HTML Files

How to enable PHP execution in .html and .htm files.

By default, the server only treats files with a .php or .phtml extension as PHP. If you need PHP code to run inside .html or .htm files as well, a quick .htaccess tweak is all it takes.

Setup

Open the .htaccess file in your site's root directory — or create one if it doesn't exist yet. Add the following lines to the top of the file:

# php -- BEGIN cPanel-generated handler, do not edit
<IfModule mime_module>
  AddType application/x-httpd-ea-php70___lsphp .php .php7 .phtml .htm .html
</IfModule>
# php -- END cPanel-generated handler, do not edit

This example uses PHP 7.0. To use a different version, swap out ea-php70 for the value that matches your setup:

PHP Version Value
PHP 7.2 ea-php72
PHP 7.0 ea-php70
PHP 5.6 ea-php56
PHP 5.3 ea-php53

Here's how the same config looks for PHP 5.6:

# php -- BEGIN cPanel-generated handler, do not edit
<IfModule mime_module>
  AddType application/x-httpd-ea-php56___lsphp .php .php5 .phtml .htm .html
</IfModule>
# php -- END cPanel-generated handler, do not edit

Once saved, your .html and .htm files will be processed by the server just like regular PHP files.

Heads up: if you ever switch PHP versions through your dashboard or cPanel, you'll need to repeat this step and update the version value in .htaccess to match.

Our products and services

Web HostingReliable hosting services for websites of any scale.
Order
VPSFlexible cloud infrastructure with full root access.
Order
Dedicated ServersBare metal servers for maximum performance.
Order

Help

If you have any questions or need assistance, please contact us through the ticket system — we're always here to help!

Need help?Our engineers will help you free of charge with any question in minutesContact us