ssi

SSI Include all files in directory?


I am new to SSI and need help with this. In one of the HTML files there is an include in UL tag

<!--#include virtual="/dataFolder/myfolder/Friday/file1.html"-->
<!--#include virtual="/dataFolder/myfolder/Friday/file2.html"-->
<!--#include virtual="/dataFolder/myfolder/Friday/file3.html"-->
<!--#include virtual="/dataFolder/myfolder/Friday/file4.html"-->
<!--#include virtual="/dataFolder/myfolder/Friday/file5.html"-->
<!--#include virtual="/dataFolder/myfolder/Friday/file6.html"-->

Is there any way I can include all of them from directory at once? If I add file7 it should be included too.

Something like

<!--#include virtual="/dataFolder/myfolder/Friday/*.html"-->

Solution

  • There’s no SSI instruction doing what you’re asking https://en.wikipedia.org/wiki/Server_Side_Includes

    You might consider exec which is supported by Apache if running an external process on every request is a viable solution for you (I woudn't recommend that)

    The exec command executes a given shell command or CGI script

    So you just need to feed it a bash command or external scripts that lists all the files in the directory

    But exec is not supporteed in nginx, here's the discussion and documentation

    I don’t know what exactly you’re trying to solve, but I would approach it differently - either use ssi include + url subrequest to the backend doing whatever you need or concatenate the files into a single bundle[s] and handle them using a regular ssi include + a local file path