Using PHP Handlers, Running HTML as PHP
  • 08 Feb 2023
  • 1 Minute to read
  • Dark
    Light

Using PHP Handlers, Running HTML as PHP

  • Dark
    Light

Article summary

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





Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.
ESC

Eddy AI, facilitating knowledge discovery through conversational intelligence