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
  • 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

Changing the code from

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


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

solved the issue I was having.

Thank you Dan.


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 agree to our terms of service, privacy policy and cookie policy

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