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...

How to password protect directories or folders

Simply click on the "Directory Privacy" icon in the "Files" section of your cPanel and the wizard...

Bandwidth Limit Exceeded - http 509 error message

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

What PHP extensions are enabled in my version of PHP?

If you wish to see what PHP extensions are enabled on your version of PHP and what other...

Internal Server Error - http 500 error

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

Powered by WHMCompleteSolution