Web www.grok2.com
grok2.gif (391 bytes)

 

.htaccess tips and tricks

 

Cause PHP processing on files with .htm or .html extension

Normally web-hosts configure their web-servers to do PHP processing only on files with the .php extension (or a few variations of this). To cause the server to process your file with .html or .htm extension for PHP, you need to add one of the following lines to your .htaccess file. Note that there is some confusion regarding what exactly will work. So depending on the Apache version, the PHP version and how the web-host has setup things, one of the several should work. If all else fails, call tech-support and find out how they've configured the "Action" rule for processing PHP and use that with the "AddHandler" rule below.

  • AddHandler php-script .html .htm
  • AddHandler php-fastcgi .html .htm (this worked for my web-host)
  • AddType application/x-httpd-php .html .htm (some people recommend this though the "AddType" rule is supposed only to tell what is the MIME type of the file with the named extension -- not how the type is handled)

Note that the "AddHandler server-parsed" (to use Server-Side Includes (SSI)) will conflict with this usage (see documentation for "AddHandler"). For any given extension, the last "AddHandler" in the .htaccess file will take precedence.

One way suggested by some people is to only configure Server-Side Includes and include a file with the .php extension. Supposedly this will cause the .php to execute as PHP. I haven't tried this myself.

 

 

Site Links
  The Books I Own
  Main Page
  Vi in Emacs
  Linux on Vaio
  Study NZ
  Utilities
  Programming Fun?
  SED FAQ
  C Language
  Source Code Browsers
  C Struct Packing
  Walt Disney World
  PPP RFCs
  FSM/HSM
  Tcl/Tk
  Photographs of Flowers
  Random Photogaphs
  Put this on your site!
  SQLite
  The Sundial Bridge
  Repetitive Strain Injury (RSI)
  Selling Software Online (MicroISV)
  Tcl Tk Life-Savers
  The Experience Shows!
  Green Tips
  .htaccess tricks
  Web-Site Development Online Tools
  Blog
 

 

 

 


Site copyright of domain owner. All rights reserved.