PDA

View Full Version : PHP not parsing .html files


analog
03-30-2001, 08:55 PM
I have noticed that php is not parsing .html files for php code.

I have a client who says it was working up until yesterday. Adding a .htaccess directive to force the parsing of .html files does not seem to be working.

Can someone look into this please?

Thanks!

Stephanie
03-30-2001, 10:28 PM
Hi Ryan -

Which domain is it? I'll take a look.

analog
03-30-2001, 10:31 PM
The domain is goblyn.net, but I also have the same prob with my site, analoghosting.com.

My test file is at www.analoghosting.com/test/php.html

Thanks!

analog
03-30-2001, 10:51 PM
Well there ya go! If I may ask, what was the problem?

Thanks for the speedy help Stephanie!

Stephanie
03-30-2001, 11:12 PM
I added this in a .htaccess file:

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

analog
03-30-2001, 11:21 PM
Just so you all don't think me stupid, I did try that for my client, and all he got was a page all black. So, I did not try it on my own site :(

So, since it obviously works, I guess we will need to be looking at his code ;)

Thanks again.

Annette
03-30-2001, 11:51 PM
A little further information on this issue:

By default, the servers should not be configured to parse all .htm and .html as php. However, for some reason, every server had the AddType entry to parse .htm(l) as php. This adds unnecessary overhead to the servers, so I removed it last night. A .htaccess specifying the directive is the proper fix for those sites wishing to parse all .htm(l) as php, as that will relegate the overhead to that site alone instead of to the entire server on which the site resides.

jmcmurry
03-31-2001, 05:24 PM
Oops, guess I messed analog's client up by reporting this in another post. When Annette "fixed" it, it caused problems. Sorry!

jm

Tuppence
04-01-2001, 02:15 PM
I am a little perplexed by this.

I have seen the argument that SSI or PHP or whatever should not be set up since it adds load to the server. Seemed perfectly reasonable till I wondered about how to set up PHP pages (another thread). When it became clear that the PHP parser has to scoot over all the text of the page it parses.

But, surely, even if all the pages were huge simply scooting through the text without doing any processing, while it would undoubtedly take processor time the additional time would be negligible in relation to the transmission times involved in sending anyone the page. Processor speed being approx 10^4 faster than transmission speed and while engaging the parser might be that slow, just scooting wouldn't be.

So my perplexity is - Is this a theoretical worry just to stop folk from setting all the options all the time or does the server performance actually slow down? And, if so why is that?

ChrisPy
04-01-2001, 03:19 PM
Server performance is actually hindered. If HM setup PHP to parse all htm/html files server wide, every request would invoke a CGI process. If their are say only 100 requests every second (assuming their are a few hundred accounts on each server) than the PHP binary would invoke high server reqources, and the server load would be much higher.

Basically, looking at this for just one account, you would be fine, but on a virtual host, with a few hundred accounts, it multiplies and will slow down legitimate PHP/CGI requests.

I go by the rule, if you don't need it 90% of the time, don't use it. It isn't any more difficult to name a page .php or .shtml (for SSI)

Hope this helps.

Annette
04-01-2001, 07:50 PM
Tony, the difference is in parsing every single html file on the server as php (ssi, whatever) and just doing that for one domain. You might not notice it for one site. But if every site, server-wide has to invoke the parser for a basic html page, you notice a hit in performance.