...

View Full Version : HELP: SSI not working for HTML?



niic
02-13-2011, 07:20 PM
Hi all,

Just wondering if someone may shed some light on why SSI would work for my php pages but not my HTML ones?

.htaccess at the site root:
Options +Includes
AddHandler server-parsed .shtml

PHP (works):
<?php include("include/copyright.shtml"); ?>

HTML (fails):
<!--#include virtual="/include/copyright.shtml"-->

The php include finds the file no worries. It sits in a dir called 'include' one level above the root. If I try and target the same location with HTML I get the expected error below:
[an error occurred while processing this directive]

If I stick the copyright.shtml file at the root and pass <!--#include virtual="/copyright.shtml"--> it works fine or even if I send it "../copyright.shtml" it works fine. Why can't HTML locate the file if it sits one level above root??

I don't want to use the FILE command because I don't want the SSI file being evaluated sitting in the same dir as the html it is being served to. You can't use "../" with that anyway so VIRTUAL is your only choice so what am I doing wrong?

Any help would be greatly appreciated. Thanks all!

Cheers,
Nick.

VIPStephan
02-13-2011, 08:40 PM
Well the path of the SSI looks like you’re looking for the file at the root level, not one level above the root. The PHP include looks for the file one level below the current one.

niic
02-13-2011, 08:56 PM
...that's because the pages (php/html) are in different locations relative to where the SSI lives!

Here is the layout:

PHP:
root/index.php

HTML:
root/common/myPage.html

SSI:
root/include/copyright.shtml



Well the path of the SSI looks like you’re looking for the file at the root level, not one level above the root. The PHP include looks for the file one level below the current one.

The SSI files are all stored in one location root/include and everything throughout the rest of the site I want to reference that location. The index.php and the directory include exist at the same level so that syntax is correct, no need for a slash.

Using a slash in html will assume the sites root level. From there I'm wanting to then go into include ...but for some reason I can't reach it.

That make sense?

Apostropartheid
02-14-2011, 04:20 PM
You've got confused.
The file which has to be parsed by the server is the file you're including from, not the one you're including. SSIs are not pure HTML (which is why the SHTML extension is generally used if you're using them). Currently you have a PHP document which you're expecting not to be parsed as PHP, which isn't going to happen.

In short: it should be index.shtml, not index.php.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum