2

I using server side includes to organize my files.

The nested files do not seem to work. For eg:-

index.shtml - this works fine

<!doctype html>
<html lang="en">
    <!--#include virtual="partials/head.shtml"-->
<body>
<!--#include virtual="partials/components/ads/horizontal-banner.shtml"-->
<div id="site-wrapper">
    <header id="site-header">
        <!--#include virtual="partials/header.shtml"-->
    </header>

    <div id="site-body">
        <!--#include virtual="partials/pages/home.shtml"-->
    </div>

    <footer id="site-footer">
        <!--#include virtual="partials/footer.shtml"-->
    </footer>
</div>
<!--#include virtual="partials/common.shtml"-->

inside home.shtml, there is another call

<!--#include virtual="../components/newsletter.shtml"-->

Following is the project structure :-

project
 - css
 - assets
 - js
 - partials
   - components
      - ads
        horizontal-banner.shtml
        vertical-banner.shtml
      newsletter.shtml
      help.shtml
   - pages
      home.shtml
      about.shtml
   header.shtml
   footer.shtml
   head.shtml
   common.shtml
index.shtml
Stacy J
  • 2,721
  • 15
  • 58
  • 92

1 Answers1

0

Look at the Apache's documentation - Server Side Includes:

Using an include file for a header and/or a footer can reduce the burden of these updates. You just have to make one footer file, and then include it into each page with the include SSI command. The include function can determine what file to include with either the file attribute, or the virtual attribute. 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. The virtual attribute is probably more useful, and should specify a URL relative to the document being served. It can start with a /, but must be on the same server as the file being served.

Try to change the home.shtml like this:

<!--#include virtual="partials/components/newsletter.shtml"-->

.. and the newsletter.shtml file should be changed in the similar manner.

Mateusz Kleinert
  • 1,316
  • 11
  • 20
  • 1
    It worked when I placed the folder inside htdocs inside xampp. When I place it in a normal directory, it doesn't work. I don't know why.... – Stacy J May 24 '17 at 14:21
  • Have you tried to look at the Apache's access and error log files? There should be an information about incorrect path if the location is the problem. – Mateusz Kleinert May 24 '17 at 14:37