How to Run HTML Files as PHP Scripts

You can run files with an .html (or other) extension in PHP by creating or modifying an .htaccess file in the same folder as the HTML file. The .htaccess file should include the following line, depending on your current setup:

For sites using our Web Hosting, Cloud or Dedicated product with CloudLinux and EA4/LSAPI:

AddHandler application/x-httpd-lsphp .htm .html .shtml

For sites using our Web Hosting, Cloud or Dedicated product without CloudLinux or with EA3/suPHP:

AddHandler application/x-httpd-ea-php55 .htm .html .shtml
AddHandler application/x-httpd-ea-php56 .htm .html .shtml
AddHandler application/x-httpd-ea-php70 .htm .html .shtml

You can also add other extensions at the end of this line, separated by a space, if you need them. With this configuration, .html and .htm files can also include PHP code.

 

Article ID: #HC5250

Was this answer helpful?