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)

Junior Member

5+ Year Member

joined:Oct 1, 2008
votes: 0

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

joined:Aug 10, 2004
votes: 10

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)

Junior Member

5+ Year Member

joined:Dec 11, 2007
votes: 0

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)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 7, 2003
posts: 1179
votes: 0

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]


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members