How to get .html pages to compile PHP code

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
eggerda
Forum Newbie
Posts: 2
Joined: Fri Sep 09, 2005 5:23 pm

How to get .html pages to compile PHP code

Post by eggerda »

Hello,

I am a novice to PHP and am working with someone who wants to have all of the pages on their site with .html extensions, but wants those pages to be able to compile PHP.

Is this possible? If so, how, and is it easy?

Thanks,

Dan

P.S. It's a standard Unix webhost using PHP 4.0
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

quite simple in most servers, you simply map the file extension to be used by php

Code: Select all

<IfModule mod_mime.c>
AddType application/x-httpd-php .php
</IfModule>
on Apache servers...
deltawing
Forum Commoner
Posts: 46
Joined: Tue Jun 14, 2005 2:55 pm

Post by deltawing »

I'm assuming you're using Apache here. If you have access to the httpd.conf file, there's a section that looks like this:

AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .phtml

Just add this line underneath:

AddType application/x-httpd-php .html

The trouble is, if its a hosting company, you probably won't have access to the httpd.conf file. You could ask your hosting company to do it for you, but I doubt they will, because that'll affect other users too.

Edit: Damn, beaten to it.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

deltawing wrote:Edit: Damn, beaten to it.
mwhahahahahha it's all apart of my diabolical plan.. :twisted:
eggerda
Forum Newbie
Posts: 2
Joined: Fri Sep 09, 2005 5:23 pm

Post by eggerda »

Unfortunately, I am using servers at a hosting company.

Is there no other way to do it, or to make it so it won't effect other sites on the same server? I'm keeping my fingers crossed here...

Dan
deltawing
Forum Commoner
Posts: 46
Joined: Tue Jun 14, 2005 2:55 pm

Post by deltawing »

feyd wrote:
deltawing wrote:Edit: Damn, beaten to it.
mwhahahahahha it's all apart of my diabolical plan.. :twisted:
You were two seconds ahead of me! Diabolical is the word.

I'm trying to think of some sort of good programming practice pun on that. Ideas, anyone?

And no, sorry. I can't think that there is. You could try sending your hosting company an email asking them if it would be possible for them to set that up for you. It all depends on how they have set up the shared server, and I don't really know how that stuff works.
Last edited by deltawing on Fri Sep 09, 2005 6:27 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

hosts often make it accessible in some fashion.. if you're using cpanel for the control panel, go through the mime-types menu to add it. I'm not entirely sure about other cp's
User avatar
William
Forum Contributor
Posts: 332
Joined: Sat Oct 25, 2003 4:03 am
Location: New York City

Post by William »

Edit your .htaccess file? Thats usually what cPanel does is just add stuff to his .htaccess file.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

hmmm, I could have swore remembering AddType was only allowed in the config, but looking it up, nope.. so yeah, into an .htaccess file will also do the trick.
User avatar
William
Forum Contributor
Posts: 332
Joined: Sat Oct 25, 2003 4:03 am
Location: New York City

Post by William »

The only reason I knew that was because a project I am working on was going to have the extention .xms for all of its files. But then we decided not to because then it would have to only be done with Apache.
Post Reply