Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
May 25, 2012, 08:37:39 AM

Pages: [1]   Go Down
  Print  
Author Topic: Apache/PHP - embedding php in html  (Read 609 times)
womeninconsulting
Space Explorer
***
Offline Offline

Posts: 9


WWW
« on: April 04, 2003, 02:12:00 AM »

Hi, How do I get apache to run my php embedded in a *.html page? I know how to do this in httpd.conf file but not using the CPanel.
Logged
Ed
Berserker Poster
*****
Offline Offline

Posts: 5208



WWW
« Reply #1 on: April 04, 2003, 02:25:00 AM »

goto CPanel, and click on apache handlers.

You can enter the extension, .html there, and then the way you want the system to handle it (eg.. parse as php.).

I'm not sure the exat code for the handler, but it would be something like this:

.html server-parsed

(each word in each box)

- Ed
Logged

Ed
Berserker Poster
*****
Offline Offline

Posts: 5208



WWW
« Reply #2 on: April 04, 2003, 02:35:00 AM »

Ok.. just did a quick double check, and I think thats the right code!

In the first box enter: .html
in the second enter: server-parsed

Once you click the button, you should see it in the list.

- Ed
Logged

womeninconsulting
Space Explorer
***
Offline Offline

Posts: 9


WWW
« Reply #3 on: April 04, 2003, 02:53:00 AM »

Hi Ed, I tried that and saw it in the list, but it didn't work on the site. Do I need to restart Apache somehow?

I've also tried the following:

  php4_module
  server-parsed
  type-map

BUT none of them worked

Alternately, the Apache httpd.conf file could include the following directive (except I'm not sure how the vhosts are configured, but here itis anyway)

   LoadModule php4_module <some/directory/file>
   AddModule mod_php4.c
   AddType application/x-httpd php .php .php3 .php4 .phtml .htm .html .shtml
   AddType application/x-httpd-php-source .phps

Anyway, still trying to get it to work...
Logged
womeninconsulting
Space Explorer
***
Offline Offline

Posts: 9


WWW
« Reply #4 on: April 04, 2003, 02:55:00 AM »

oops. ed's not your handle, is it? it's your function, right, kata?
-artypants
Logged
Ed
Berserker Poster
*****
Offline Offline

Posts: 5208



WWW
« Reply #5 on: April 04, 2003, 03:09:00 PM »

I guess you could 'Ed' my function ;-) Whenever someone calls the function Ed(); I usually do respond, though...

Ed($);
Ed(Food);
usually respond faster :-)
(Ed's my name)

----
Ok...

Just did a bit more research. I personally don't use PHP on my site (yet), so I do have a quick way to test this, but...

CPANEL:

Click on MIME types
Enter: application/x-httpd-php (in the first box)
and: .php .php4 .php3 .phtml .html (in the 2nd)

Try that..

- Ed
  "[wave]"
Logged

jgoosink
Newbie
*
Offline Offline

Posts: 3


WWW
« Reply #6 on: April 06, 2003, 03:43:04 AM »

What works very well with me is change the *.html into *.php . Then the file will be parsed by php anyway. If you want html-files to be parsed by php then all html-files (also the static ones) will be parsed, which might make your site some what slower.

Jos
Logged
KJones
Galactic Royalty
*****
Offline Offline

Posts: 327



WWW
« Reply #7 on: April 06, 2003, 06:07:35 AM »

Quote from: jgoosink
What works very well with me is change the *.html into *.php .


The problem with that is, if you have an existing page that you want to use php on you don't want to change the name... if someone has that page bookmarked they won't be able to find it.

It would be nice to keep the .html and still use php. How much slower will that make the site? Painfully slow?


Kel
Logged

"I believe that this nation should commit itself to achieving the goal, before this decade is out, of landing a man on the moon and returning him safely to the earth." - John F. Kennedy

stephan
Guest
« Reply #8 on: April 06, 2003, 06:40:49 AM »

The reason PHP files are called whatever.php is so that they are run by the server instead of just being displayed.

The difference in time, isn't great. In fact, probably not noticeable at all, but it is better to have pages which do not include PHP code, named as whatever.html

It's just kinder on the servers.

As for old links, if you were feeling particularly clever, you could write a .htaccess file and put it in your public_html directory.

Something like this would go in it:



Code:

ErrorDocument  404  /errorpage.php?error=404


Then, make errorpage.php and use "HTTP_REFERER" to get the name of the page that the user came from (this would hopefully display the page they were trying to get to).

Then, put HTTP_REFERER into a string, cut off the .html and rename it to .php

Then redirect the user to that page.

If you're good at php, that should work
Logged
KJones
Galactic Royalty
*****
Offline Offline

Posts: 327



WWW
« Reply #9 on: April 06, 2003, 07:13:52 AM »

In my case it would be easier just to make the .html files run like .php files because all of my pages contain the same header and sidebar, and I have over 90 existing pages. There aren't any pages that would have just HTML, so it probably wouldn't put any more strain on the server than naming all my files .php would, right?.

Would using PHP instead of just HTML increase my bandwidth useage? I'm no where near using 20GB, but still...


Kel
Logged

"I believe that this nation should commit itself to achieving the goal, before this decade is out, of landing a man on the moon and returning him safely to the earth." - John F. Kennedy

stephan
Guest
« Reply #10 on: April 06, 2003, 08:02:20 AM »

No, it won't increase your bandwidth, and it won't put any strain on the server.

It's not much of a difference really Very Happy
Logged
womeninconsulting
Space Explorer
***
Offline Offline

Posts: 9


WWW
« Reply #11 on: April 06, 2003, 11:49:42 PM »

I tried the mime type thing that ed suggested but it's not working. Instead, I'm getting wierd behavior, one of my html pages is getting downloaded and opened with a browser pointing to my local copy as if html was a new mime type...? So instead of http://mydomain.com/file.html, I see a download happen, a new browser window open with the address c:\WINDOWS\temporary files\Content.IE5\KHKDY3OH\file[1].html

This isn't happening site-wide so I don't really understand what's going on.

As for the performance hit, I can't imagine it's any at all since it's a module that's running all the time. But I'm certainly no expert. So, until I understand more, this thing's getting turned off.
Logged
stephan
Guest
« Reply #12 on: April 07, 2003, 02:34:19 AM »

You must have made a mistake, because the server is sending you the file to open, instead of running it.

PHP is running all the time, in a way, but it only does something when it is given some php to run, so it does make a difference.

Even though it's a small difference (tiny)
Logged
Pages: [1]   Go Up
  Print  
 
Jump to: