Get The Most Affordable Hosting in the World!

Starting at just $1.87/month, Vercaa offers unbeatable pricing for world-class web hosting services.

Fast, reliable, and secure hosting to power your website without breaking the bank. Plus, enjoy a free CDN for faster loading times worldwide!

Get Started Now!

A few days ago one of our techs was facing a strange issue while trying to execute PHP in HTML on EasyApache 4 from cPanel. After upgrading to EA4, a previously working .htaccess hack that was used to execute PHP in HTML was no longer working. This was the rule we used for our customer:

AddHandler application/x-httpd-php5 .html

Tried several things, even a simple test.html file with this content inside, and it was not executed ok:

<html>
<head></head>
<body>
Hello, today is <?php echo date('l, F jS, Y'); ?>.
</body>
</html>

While using EasyApache 3 it was working, but not on EA4. EA4 was built with latest version of Apache 2.4 with PHP 5.5, 5.6, 7.0 and 7.1. The file was not prompting to download the file, it was just not executing any php code at all and was displaying only the HTML code.

How can I Execute PHP in HTML on EasyApache 4?

EasyApache 4 introduced many important changes in the way cPanel handles Apache and PHP modules managemnet. One of them is the way EA4 manages PHP, right now thanks to the introduction of MultiPHP, the old hack to execute PHP in HTML no longer works because the PHP interpreter is different.

The way to execute PHP in HTML on EasyApache 4 is using the new PHP handlers that are coming with MultiPHP from cPanel. In this case, the site was using PHP 5.6, and this was the code that did work on the .htaccess file:

AddHandler application/x-httpd-ea-php55 .html

The End! should you have any inquiries, we encourage you to reach out to the Vercaa Support Center without hesitation.
Je li Vam ovaj odgovor pomogao? 1 Korisnici koji smatraju članak korisnim (1 Glasovi)