How to run php code in an html page?

If you want to run php code in your html web pages we recommend that you rename them using the ".php" suffix and run php natively, i.e. index.php rather than index.html.

However, if you cannot or do not wish to rename your html pages you can add the following code to your .htaccess file:

AddHandler application/x-httpd-php5 .html .htm

This will then force any pages in your site with a ".html" or ".htm" extension to be treated as though they had a ".php" extension.

We recommended that you never allow html pages to automatically handle php or shtml, because this forces all of your html pages to be processed by the server first.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

htaccess code examples

Your .htaccess file is commonly used to change the way that people access or view your site. This...

What does SSI (Server Side Includes) mean?

SSI or Server Side Includes are used to add contents of other files or variables from the server...

What is a shtml file type?

A web file type with the suffix of ".shtml" (rather than the usual ".html" or ".htm") indicates...

Internal Server Error - http 500 error

Internal server errors can be caused by a few different things. Please check the Error Logs in...

Bandwidth Limit Exceeded - http 509 error message

If you are seeing the following http 509 Bandwidth Limit Exceeded error it is because you have...

Powered by WHMCompleteSolution