How can I make .html files be interpreted as .php files by the server?
In this article, you will learn the procedure by which .html files are interpreted as .php files by the server.
Shared server steps
In order for the server to interpret .html files as .php files, it is necessary to add the lines below in the .htaccess file in the directory where the .html file is located or in the root directory of the hosting account.
AddHandler application/x-httpd-ea-php56-lsphp /opt/cpanel/ea-php56/root/usr/bin/lsphp .html
#AddHandler application/x-httpd-ea-php70-lsphp /opt/cpanel/ea-php70/root/usr/bin/lsphp .html
#application/x-httpd-ea-php71-lsphp /opt/cpanel/ea-php71/root/usr/bin/lsphp .html
#application/x-httpd-ea-php72-lsphp /opt/cpanel/ea-php72/root/usr/bin/lsphp .html
We will uncomment the line specific to the PHP version that is set in the cPanel account, in our case PHP 5.6.
VPS Server cPanel Steps
#AddHandler application/x-httpd-ea-php56 /opt/cpanel/ea-php56/root/usr/sbin/php-fpm .html
AddHandler application/x-httpd-ea-php70 /opt/cpanel/ea-php70/root/usr/sbin/php-fpm .html
#AddHandler application/x-httpd-ea-php71 /opt/cpanel/ea-php71/root/usr/sbin/php-fpm .html
#AddHandler application/x-httpd-ea-php72 /opt/cpanel/ea-php72/root/usr/sbin/php-fpm .html
We will uncomment the specific line for the PHP version that is set in the cPanel account, in our case PHP 7.0.