How to set HTML files to run PHP Code Print

  • 36

Sometimes it can be beneficial to include PHP code within your HTML files.  Typically you would use the .PHP extension for all files that include PHP code. By instructing the server to process .HTML files as PHP file, you will slow down the response (slightly) because each file must be processed before it is returned, when normally a .HTML file is quickly returned as TEXT.

To setup your account to process HTML files as PHP, you will need to add the following Apache AddHandler directive within a .htaccess file, placed in the folder where the HTML files are located.  If you want to process all HTML files on your account as PHP, then you will need to place the .htaccess file in your base /public_html folder.

For PHP4: 

AddHandler application/x-httpd-php4 .html

For PHP5:

AddHandler application/x-httpd-php5 .html
AddType application/x-httpd-php53 .php


Was this answer helpful?

« Back