WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-19-2007, 08:18 AM
WebProWorld Member
 

Join Date: May 2007
Location: Grimsargh, UK
Posts: 37
apwade RepRank 0
Default .htm extension

I have modified my existing webpage, and under going testing i am having problems with pages with the extension .htm. These pages have php embedded in them, but they display as a htm and do not run the php code.

Does anybody know what i am doing wrong? Is it something to do with the htaccess file, currently i do not have one in the main directory (do i need one)?

Cheers,

Andrew
__________________
Discount shopping vouchers
Reply With Quote
  #2 (permalink)  
Old 07-19-2007, 09:33 AM
WebProWorld Veteran
 

Join Date: Aug 2003
Location: Cornwall, UK
Posts: 833
speed RepRank 1
Default Re: .htm extension

The normal default configuration for web servers is that only files ending in .php will be passed to PHP for processing.

You can try adding the following to your .htaccess file to cause .htm and .html files to be treated as PHP:
Code:
AddType application/x-httpd-php .htm .html
__________________
TOLRA Micro Systems Limited US & UK Web Hosting with Continuous Data Protection
Web Directory 2 for 1 Offer : Web Directory Script
Reply With Quote
  #3 (permalink)  
Old 07-19-2007, 09:33 AM
Dubbya's Avatar
WebProWorld 1,000+ Club
 

Join Date: Nov 2006
Location: Steinbach, Manitoba, Canada
Posts: 1,260
Dubbya RepRank 3Dubbya RepRank 3
Default Re: .htm extension

I'd think that the server couldn't run .php code in a file saved with the .htm extension.

Change the file extension to .php and the server will process the scripts before it serves up the pages.
__________________
Printer ink, inkjet & toner cartridges in Canada
"Price-wise printing supplies"
inkjetOasis.ca
Reply With Quote
  #4 (permalink)  
Old 07-19-2007, 10:19 AM
wige's Avatar
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,782
wige RepRank 4wige RepRank 4wige RepRank 4wige RepRank 4
Default Re: .htm extension

Note that making this change may not be desirable if most of your pages are pure html. If you add an entry to the htaccess as suggested, all html files will be parsed for php, which could put an unnecessary load on your server. Also, if you use a doctype tag, your normal pages could break. (The <? that opens the doctype definition is a php shortcut tag.) Some shared hosts also do not allow extensions to be changed in this way. If this is the only php page and you don't want the php extension, I would suggest using mod rewrite if that is an option on your server.
__________________
The best way to learn anything, is to question everything.
Reply With Quote
  #5 (permalink)  
Old 07-20-2007, 02:31 AM
WebProWorld Member
 

Join Date: May 2007
Location: Grimsargh, UK
Posts: 37
apwade RepRank 0
Default Re: .htm extension

Thank you all for your help. I have opted for the addition of a .htacess file, as all my pages are php and it would not affect the load on the server.
__________________
Discount shopping vouchers
Reply With Quote
  #6 (permalink)  
Old 07-23-2007, 05:40 AM
jordanmcclements's Avatar
WebProWorld Veteran
 

Join Date: Oct 2003
Location: Northern Ireland
Posts: 498
jordanmcclements RepRank 1
Default Re: .htm extension

Depending on what way your web server is configured you may have to add the following line to .htaccess instead of the one mentioned above (this is what I had to do to allow .htm files to be parsed as .php files):-

AddHandler php-script .htm

It worked perfectly for me with no messing around having to redirect pages etc..
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
SEO Extension for Firefox flood6 Search Engine Optimization Forum 56 02-09-2006 10:03 AM
Firefox Gets SEO Extension jmiller Search Engine Optimization Forum 1 10-31-2005 11:33 AM
Firefox extension DB problems AjiNIMC Web Programming Discussion Forum 0 06-17-2005 01:02 PM
The next most popluar extension after .com kikkertm Domain Discussion Forum 9 05-06-2004 08:33 PM
Do you know about file extension FLM kiumars Flash Discussion Forum 7 04-10-2004 05:45 AM


Search Engine Optimization by vBSEO 3.2.0