homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Gold Sponsor 2015!
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

Calling external php in htm files
Is this possible?

5+ Year Member

Msg#: 3821802 posted 11:09 am on Jan 8, 2009 (gmt 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?



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

Msg#: 3821802 posted 12:48 pm on Jan 8, 2009 (gmt 0)

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


5+ Year Member

Msg#: 3821802 posted 2:04 am on Jan 11, 2009 (gmt 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?


WebmasterWorld Senior Member 10+ Year Member

Msg#: 3821802 posted 3:16 am on Jan 11, 2009 (gmt 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]

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved