Forum Moderators: coopster

Message Too Old, No Replies

PHP SSI in .html problem

PHP SSI Problem in .html

         

ajeremie

2:32 pm on Mar 29, 2006 (gmt 0)

10+ Year Member



I am migrating to a new server and none of my old PHP SSI do work anymore.

Old config: Plesk 7.5.4 with PHP 4.3.8 running Apache 2.0.50 on Fedora
New Config: Plesk 7.5.4 with PHP 4.3.11 running Apache 2.0.53 on Fedora

Code:
The code in question is on an HTML page:
<!--#include virtual="includes/header.php" -->

Works perfectly on old server: <snipped url per TOS [webmasterworld.com]> all the header/footer and right sections of the site are all PHP SSI, but on the new server the page will not even display.

I have tried to replace them with SHTML on the new server and it works fine, so SSI is turned on properly. All my PHP pages of the site do work properly and all the PHP SSI on PHP pages work perfectly. Just when I have PHP SSI in .HTML files that it craps out.

I tried a bunch of .htaccess edits but none of them fully satisfied me as they either serve the HTML page with the PHP SSI but then non of the stand alone PHP pages worked anymore or even worse I get asked to download the file.

Some people suggested that I needed in my httpd.conf file:

AddType text/html .shtml
AddHandler server-parsed .shtml
AddHandler server-parsed .html
XBitHack On

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml .html

My httpd.conf file is already set that way. My belief is that it can be solved with an edit on the .htaccess but cannot find the good combo of edits to make it all work as before.

Since the site is well indexed and ranked by search engine, converting all my pages to PHP is not an option. Changing to SHTML all the includes is not an option either as I have dynamic script in the PHP includes.

If you believe you can be of help to solve the problem please let me know.

Cheers,
- Jeremie

[edited by: coopster at 2:36 pm (utc) on Mar. 29, 2006]
[edit reason] removed url per TOS [webmasterworld.com] [/edit]

henry0

5:27 pm on Mar 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to Webmasterworld!

since you include a PHP within a HTML you need to have HTML parsing PHP
plus it is a known fact with your config

here is the line you need adding
<<<
AddType application/x-httpd-php .html
>>>

Hope it does it

maccas

5:41 pm on Mar 29, 2006 (gmt 0)

10+ Year Member



What does just this in your .htaccess do?

AddType text/x-server-parsed-html .html

henry0

5:59 pm on Mar 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Mostly those lines go together
text/x-server-parsed-html .html
AddType text/x-server-parsed-html .htm

it allows all HTML to be parsed for server side include

ajeremie

6:42 pm on Mar 29, 2006 (gmt 0)

10+ Year Member



Tks henry0,

But the:
<<<
AddType application/x-httpd-php .html
>>>
Does not do it on the new server. It still does not show anything.

I also tried the following:
<<<
text/x-server-parsed-html .html
AddType text/x-server-parsed-html .htm
>>>
That edit in the .htaccess gives me a "500 Internal Server Error"

Any other idea?

Note: I compared my old http.conf files and the only difference is that the old one has:
LoadModule webapp_module modules/mod_webapp.so
and the new one has:
#LoadModule webapp_module modules/mod_webapp.so

henry0

11:40 pm on Mar 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry about the bad news

You should either try posting in the Apache forum
or ask our PHP mods to move your thread in Apache

ajeremie

1:14 am on Mar 30, 2006 (gmt 0)

10+ Year Member



I tried

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

And it kind of works but it only parses about half the page. And on some small pages it parses it all. Looks like it limits the bit size of what it will parse. any settings I can change around?

henry0

11:57 am on Mar 30, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am thinking about something
since your HTML will now parse PHP
why don't you forget about SSI
and include you PHP as PHP
within your HTML
Try a regular PHP include
<<<
<?
include('header.php');
?>
>>>

if it does not work I hope someone else will have an idea
or as I said post in: Apache forum.

ajeremie

1:58 pm on Mar 30, 2006 (gmt 0)

10+ Year Member



Dude, you rock.

It works perfectly and since I was anyway parsing PHP code on all of my pages, it does not even slow down the server anymore than it was before.

Kind of floored by it but will take it and run with it. I will post shortly the problem and work around on the apache section, as well as all the other board I have been asking for it.

Cheers,
- Jeremie

henry0

2:14 pm on Mar 30, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Glad you got it sorted out :)

jatar_k

3:27 pm on Mar 30, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



just as a point of clarity, it is very difficult to have apache parse the same file for SSI and php (or any second language). It is not recommended because it does have a tendency to confuse the server. There are ways to make it work but there is no point.

The answer is, as henry stated, in message 8.

use php includes.

coopster

3:39 pm on Mar 30, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I agree with the other fellas here, use the php includes -- much easier and much cleaner.

There is a thread that describes in detail how you can do both and I will post the link here just so you can read about how it is done, for peace of mind:

When parsing SSI's, PHP files don't work [webmasterworld.com]

That link and the links from that page describe in detail how SSI works, and how you can implement both SSI and PHP together.

But, save yourself the headaches, use php includes().

ajeremie

3:57 pm on Mar 30, 2006 (gmt 0)

10+ Year Member



Based on henry0 suggestion, I did that and it all works perfectly now. Tks.