Parsing Problem
August 11, 2004 12:17 PM   Subscribe

htaccess, SSI, and PHP parsing. Can one file get both php and ssi parsing? if yes, how, if not, help! [*]
posted by gramcracker to Computers & Internet (10 answers total)
 
Why on earth would you want that?
posted by cmonkey at 12:19 PM on August 11, 2004


Response by poster: I've hacked through Wordpress to make a basic CMS for a project (Wordpress is PHP). The master site that I have to integrate *my* site with uses SSI's instead of PHP includes, and I need to use SSI's to pull their Dreamweaver templated pages in. (I may just have to change the SSI's and turn them into PHP includes, ruining their template, but I'd prefer not to.)

Scoured the net, and have this mess of an htaccess:

Options +Includes
AddType text/x-server-parsed-html .html .php
AddType application/x-httpd-php .php
AddType text/html .php
AddHandler server-parsed .shtml .html .htm .php

I can get one or the other to work, but not both. Tried all different permutations, but sometimes it makes Firefox want to *downlad* the PHP page instead of view it in the browser; other times it doesn't parse the PHP, other times it doesn't parse the SSI.
posted by gramcracker at 12:22 PM on August 11, 2004


Response by poster: I don't like it either, cmonkey. It's a big academic site that they're trying to reel in content to conform to one standard look, redesign launched in January. Branding, I guess.

And they're using HTML 4.01 with tables and spacer gifs, but that's a whole other story.
posted by gramcracker at 12:23 PM on August 11, 2004


I don't know if it can be done, (and I don't believe it can, from what I recall of apache's internals) but if I were the admin at that site I'd force you to use the PHP includes, to prevent apache from having to parse the file twice.
posted by cmonkey at 12:37 PM on August 11, 2004


This can be done, presuming that you are including the SSI portions using one of PHP's include functions.

IOW, within your php file, do:


<php include("http://domain.dom/your_ssi_file.shtml"); >


...wherever you need the SSI parsed sections.

I don't think both can exist in the same file though.
posted by tomierna at 1:02 PM on August 11, 2004


Just change your code that looks like this:

<--#include virtual="header.inc"-->

to this:

<?php include ('header.inc'); ?>
posted by mathowie at 1:19 PM on August 11, 2004


Changing your #includes to php includes is probably the most sensible thing to do. However, in the event you really needed to do something wacky like this, I believe Apache Filters can do what you're talking about -- using them, I understand you can examine and even change the output from a given handler.
posted by weston at 1:39 PM on August 11, 2004


Can you elaborate on why you don't want to use PHP includes, and how the DreamWeaver templates work?
posted by treebjen at 2:14 PM on August 11, 2004


Response by poster: I just didn't want to have to mess with their Dreamweaver templates. (The templates are basic HTML docs with Dreamweaver-specific comments that "lock" certain aspects of the page, so novices can't go messing up the layout.) It was no problem to change them, just thought I'd see if there was a way to enable both SSI and PHP so I could leave their templates alone. Thanks everyone!
posted by gramcracker at 2:25 PM on August 11, 2004


Sorry to arrive late to the party, but *cough* http://www.php.net/virtual
posted by nakedcodemonkey at 11:17 PM on August 11, 2004


« Older Bad "romantic" songs?   |   In OOP, when to use a Collection of Objects with... Newer »
This thread is closed to new comments.