- 08 Feb 2023
- 1 Minute to read
- Print
- DarkLight
Using PHP Handlers, Running HTML as PHP
- Updated on 08 Feb 2023
- 1 Minute to read
- Print
- DarkLight
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 name 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