3

I was wondering if someone could explain/have a solution for why my SSI's do not work if the file I'm including is back a directory. e.g.

  • index.html
  • gallery/pictures.html
  • ssi-files/navigation.html

This works when I use it in my index.html file:

<!--#include file="ssi-files/navigation.html"-->

This does not work when I use it in my gallery/pictures.html file:

<!--#include file="../ssi-files/navigation.html"-->

Help in solving this one would be much appreciated.

  • 2
    From the Apache Tutorial: Introduction to Server Side Includes: The file attribute is a file path, relative to the current directory. That means that it cannot be an absolute file path (starting with /), nor can it contain ../ as part of that path.. So you might consider using the virtual attribute instead of file which allows you to specify a URL relative to the document being served. That's often used in footers where pages are nested in different directories (see "Including a standard footer" in that link). – dan May 30 '18 at 5:18
  • 1
    Ah perfect, thank you very much for the help :) – SteveyG May 30 '18 at 8:58
  • No problem. Feel free to add that as an answer below, or whatever worked for you, and accept it when you can (you'll earn some more reputation points). – dan May 30 '18 at 9:20
2

Changing the code from

<!--#include file="...

to

<!--#include virtual="...

solved the issue I was having.

Thank you Dan.

0

Files that use SSI (Server Side Includes) need to be named with an .shmtl extension. Therefore, if you have markup in your webpage calling <!-- #include virtual..., that file needs to be called example.shtml. This will let the server know what type of code to look for and how to read it.

Server Side Includes ala' Wikipedia

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.