.htm extension resolving to .php?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Col. Panic
Forum Newbie
Posts: 1
Joined: Thu Feb 02, 2006 10:29 am

.htm extension resolving to .php?

Post by Col. Panic »

I just discovered an error in a script - but it has been functioning nonetheless for years.

I'm using a script named club_store_parser.php. But I discovered that in another script I have a link to it as club_store_parser.htm (and there is no document with that name anywhere).

So, it'll call something like

../../club_store/club_store_parser.htm?page=club_store_detail&refer=shed&id=02500363

when it should really be

../../club_store/club_store_parser.php?page=club_store_detail&refer=shed&id=02500363

But it works just fine - I've tested it thoroughly.

I was wondering -- why is this? The browser can't find a file of that name with .htm, so it loads the one with .php?
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

Several reasons

You could be mod_rewriting all .php to .htm, you could also have .htm as a PHP handled file (which would not affect normal .htm files except for overhead of parsing them for PHP). Your host could have also done this
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it's likely the server recognizing that the extension is off and rewrites it.. or someone put a redirection into the server..
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Yeah... something like:
ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .htm

# For PHP 4
Action application/x-httpd-php "/php/php.exe"

# For PHP 5
Action application/x-httpd-php "/php/php-cgi.exe"
Post Reply