Updated: 28 September 2026 · Applies to: cPanel & WHM 138, PHP 8.1 to 8.4

To run PHP code inside files ending in .html, tell the web server to hand those files to PHP. The old line AddType application/x-httpd-php5 .html was for PHP 5 and no longer works.

Recommended: keep the .html addresses, use .php files

Rename the pages to .php and add this to public_html/.htaccess. Visitors and search engines keep using the .html addresses, and the server quietly runs the matching .php file:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+)\.html$ $1.php [L]

This works with every PHP handler, including PHP-FPM, and pages without PHP code stay fast.

Alternative: run .html files through PHP

cPanel sets the PHP version with a handler line in .htaccess (for example AddHandler application/x-httpd-ea-php83 .php .php8 .phtml). On domains that do not use PHP-FPM, a separate line below cPanel's block makes .html files run as PHP (use the same version as cPanel's line, and do not edit inside the lines marked "cPanel-generated handler, do not edit"):

AddHandler application/x-httpd-ea-php83 .html .htm

PHP-FPM, which Ucartz servers use for many sites, only runs files ending in .php (and similar) for security, so this line alone does not work there. Use the recommended method, or ask our support team.

Test with a file test.html containing <?php echo "PHP works"; ?>: if the page shows just "PHP works", PHP ran it. Delete the test file afterwards.

Note: The old application/x-httpd-php5 handlers from PHP 5 no longer exist and do nothing on current servers.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Managed cPanel VPS

cPanel included; we handle updates, security and monitoring.

Server management

on-demand administration, hardening, migrations and monitoring.

Was this answer helpful?

Still stuck? Open a ticket