Results 1 to 1 of 1

Thread: Processing .html, .htm files through PHP

  1. #1

    Default Processing .html, .htm files through PHP

    Normally, .html and .htm files are not processed by the server, as they usually do not contain PHP or other scripting code, so they can be sent straight to the browser. Thats why pages with PHP code almost always end in .php, so the server knows to process them first.

    However, there may be some rare circumstances in which you want your .htm or .html pages parsed through PHP, if they contain PHP code and you cant rename them with a .php extension.

    Simply add the following line to your .htaccess file in the public_html folder:

    • AddType application/x-httpd-php5 .htm .html

    That will process all .htm and .html files through PHP first, thereby processing php code in them.

    However, it is highly recommended that you never allow html pages to automatically handle php, because this forces all of your html pages to be processed by the server first, which slightly increases processing time. If most of your .html or .htm files do not have PHP code in them, this is a waste of server processing. Instead, please rename your files to .php if they contain php code. The method above, should be used only if that is not viable option. Simple put, your site will be faster if only pages containing PHP code are processed by having a .php extension, and not processing .html or .htm pages, which should not have PHP code.

    -Cameron L.
    Last edited by Cameron L; November 11th, 2010 at 02:49 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts