Welcome to WebmasterWorld Guest from

Forum Moderators: incrediBILL

Message Too Old, No Replies

Calling external php in htm files

Is this possible?



11:09 am on Jan 8, 2009 (gmt 0)

5+ Year Member

The site I maintain uses htm files. I've heard these won't run php scripts and dreamweaver certainly throws a wobbly if I attempt to use a <?php?> tag.
Is it possible to use php in htm?
Is it possible to convert htm to html?


12:48 pm on Jan 8, 2009 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

assuming apache, you can use the AddHandler directive of the mod_mime module:
AddHandler Directive - mod_mime - Apache HTTP Server [httpd.apache.org]

something like this might work:
AddHandler php5-script .html


2:04 am on Jan 11, 2009 (gmt 0)

5+ Year Member

HTML files and htm files can run php scripts, with the php tags.And you can just change the file name to reflect htm or html. Is this what you wanted to know?


3:16 am on Jan 11, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

you can use a php include file, make a file called text.php (or what ever name you choose) containing whatever you want to include on the web page and upload to your web space, copy and paste the code below to where you want the included code to appear on your web page. it requires the full server path to text.php

include ("/full server path to your file/text.php");


converting htm to html using .htaccess file

using notepad copy the code below and save as htaccess, upload to your web space and rename as .htaccess

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.htm$ $1.html [NC]


Featured Threads

Hot Threads This Week

Hot Threads This Month