Forum Moderators: phranque

Message Too Old, No Replies

PHP SSI in .html Problem & Work-around

Calling PHP SSI from .html on a strange server.

         

ajeremie

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

10+ Year Member



PROBLEM

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, but on the new server the page would not even display. Was giving a "The page cannot be displayed" error.

I tried to replace them with SHTML on the new server and it worked fine, so SSI was turned on properly. All my PHP pages of the site did work and all the PHP SSI on PHP pages worked perfectly. Just when I had PHP SSI in .HTML files that it craped out.

Some people suggested edits to my httpd.conf file, but my httpd.conf file was already set the way, they suggested. My belief was that it could be solved with an edit on the .htaccess but could not 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 was not an option. Changing to SHTML all the includes was not an option either as I have dynamic script in the PHP includes.

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.

WORK-AROUND

Well, it was on the .htaccess but could not figure it out until henry0(http://www.webmasterworld.com/profile.cgi?action=view&member=henry0) came to the rescue and made me think that I had missed a few more possible edit. one of them:
<<<
AddHandler application/x-httpd-php .php .html .htm
>>>
That did it, but the html pages did not all respond properly to teh chaneg and the solution was again given by henry0:
"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');
?>
>>>
"

It all worked prefectly, the edits on the site was painless and we are abel to keep our actuall strcuture.

I have to say it was my first time using this forum and i am glad I join.

Cheers,
- Jeremie

coopster

4:06 pm on Mar 30, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Great to hear, ajeremie.

Yeah, that henry0 is quite helpful over in php. Glad you got it sorted and thanks for the update.

[webmasterworld.com...]