Forum Moderators: coopster & phranque

Message Too Old, No Replies

Getting HTML files to execute

Trickin' it out all over the place

         

Filipe

9:50 pm on May 10, 2002 (gmt 0)

10+ Year Member



Is there a way to get *.htm/*.html files to run as ASP or PHP scripts?

ergophobe

10:01 pm on May 10, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I can think of three possible ways. Maybe more experienced people know better ways and which one should be preferred. Both of these pertain only to Apache (AFAIK).

In your httpd.conf file, find your PHP AddType

AddType application/x-httpd-php .php

Change it to something like

AddType application/x-httpd-php .php .htm .html

That should result in anything with those three extensions executing as php and that is what I would do.

Two other ways might work for you too. You could use mod_rewrite to rewrite all *.html urls to *.php and then rename all .html files (I realize that's not what you asked, but it would mean that any links in Google or whatever would remain valid and your result would be the same).

You can also try the ForceType directive which will force anything to execute as the given type. I paste this in from the Apache manual

ForceType directive

Syntax: ForceType media-type
Context: directory, .htaccess
Status: Base
Module: mod_mime
Compatibility: ForceType is only available in Apache 1.1 and later.

When placed into an .htaccess file or a <Directory> or <Location> section, this directive forces all matching files to be served as the content type given by media type. For example, if you had a directory full of GIF files, but did not want to label them all with ".gif", you might want to use:

ForceType image/gif

Note that this will override any filename extensions that might determine the media type.

toadhall

10:22 pm on May 10, 2002 (gmt 0)

10+ Year Member



Check out this page:
[webmasterworld.com ]
I found it by searching under "htaccess php html".
Site search [searchengineworld.com] is in the menu at the top.