Forum Moderators: phranque

Message Too Old, No Replies

Run a Specific .html File as PHP

         

HoboTraveler

11:18 am on Mar 18, 2009 (gmt 0)

10+ Year Member



Hi All,

I have a bunch of .html files in a directory.

I need to run a specific files, test.html as PHP. Because test.html has PHP code in it.

How do I create a .htaccess rule so that test.html is executed as PHP?

I added this bit in the .htaccess and it did not work
AddType application/x-httpd-php test.html

TIA

jdMorgan

12:00 pm on Mar 18, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See the <Files> and <FilesMatch> containers in Apache core. Code that is "wrapped" in a container is only executed if the conditions specified by that container are met.

Also note the XBitHack feature in mod_alias for tagging individual files to be executable.

Jim

HoboTraveler

6:29 pm on Mar 18, 2009 (gmt 0)

10+ Year Member



I added the following and it did not work. Any ideas?

<Files test.html>
AddType application/x-httpd-php test.html
</Files>

Caterham

8:01 pm on Mar 18, 2009 (gmt 0)

10+ Year Member



Use


<Files test.html>
SetHandler application/x-httpd-php
</Files>

You don't want to set an MIME-type.

HoboTraveler

9:30 am on Mar 19, 2009 (gmt 0)

10+ Year Member



Thanks! Works great