Using PHP Handlers, Running HTML as PHP

Follow

Apache Handlers allow you to control how Apache will manage certain file types.

When Apache recognizes a file, it has an action built in for that file type and will perform that action. If you want Apache to perform a different action, you will need to override the default handler, to perform it.

For example, if you use a file type that requires a special service in order to run, such as a file with server-side includes that is not named with a .shtml extension, you need to tell Apache to treat these files differently.


Running HTML as PHP

It is highly recommended that you don't configure HTML pages to automatically handle PHP or SHTML because this forces all of your HTML pages to be processed by the server first, which also increases your resource utilisation, and general response times.
 
It is also recommended that you rename your files to .php or.shtml whenever possible, and use .htaccess Mod Rewrite to correct the URL.

However, if you wish to choose to continue, and use PHP for standard .htm, or .html files, you will be able to add the following line to your .htaccess file.

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

Please Note, this method may not work if you are running with the "PHP Selector" configured to use a non-native PHP version, as the handler may differ.

Have more questions? Submit a request

Comments

Powered by Zendesk