Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Oct 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    HELP: SSI not working for HTML?

    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.
    Last edited by niic; 02-13-2011 at 07:23 PM.

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,665
    Thanks
    6
    Thanked 1,006 Times in 979 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    Oct 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ...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


    Quote Originally Posted by VIPStephan View Post
    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?

  • #4
    The Apostate Apostropartheid's Avatar
    Join Date
    Oct 2007
    Posts
    3,215
    Thanks
    16
    Thanked 265 Times in 263 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •