3

I'm programming for an Apache server and I need for just one specific html page (say, first.htm) to be processed as PHP script. Is it possible to set up?

ahmd0
  • 14,832
  • 29
  • 117
  • 218

3 Answers3

4

SetHandler directive can be used, too:

Forces all matching files to be processed by a handler

When placed into an .htaccess file or a or section, this directive forces all matching files to be parsed through the handler given by handler-name.

<Files first.htm>
    SetHandler application/x-httpd-php
</Files>
Salman A
  • 229,425
  • 77
  • 398
  • 489
  • 3
    +1 - This is actually the proper way to do it. AddType is for MIME types, which are a totally different concept and it was a mistake for PHP to recommend configuring it that way. The PHP docs no longer recommend using AddType and now recommend SetHandler. – Dondi Michael Stroma Jun 28 '12 at 01:54
3

Create a file called .htaccess and place it in the directory this file will be in. Add this line to ti:

<Files first.htm>
    AddType application/x-httpd-php .htm
</Files>
John Conde
  • 207,509
  • 96
  • 428
  • 469
2
<Files first.htm>
    ForceType application/x-httpd-php
</Files>
Puggan Se
  • 5,431
  • 2
  • 19
  • 45
  • Interesting. What is the difference between AddType as suggested above and ForceType? – ahmd0 Jun 27 '12 at 20:09
  • 1
    AddType have a 2nd parameter, in johns case ".htm", ForceType chane type on all files in the current scope, while AddType change the type on all files in the scope that ends whit .htm – Puggan Se Jun 27 '12 at 20:11