SSI include virtual relative path not working
Asked Answered
G

2

5

My website is set up to use SSI and it's been working great.

However, when I try to include a file via SSI it won't work for I use a relative path. For example, the following works

<html>
    <head>
        <!--#include virtual="include/head.shtml" -->
    </head>
</html>

But this does not (assume that the files exist)

<html>
    <head>
        <!--#include virtual="../include/head.shtml" -->
    </head>
</html>

Is there something I'm missing, or is there a way I can get more information regarding this error.

Galley answered 3/11, 2015 at 5:7 Comment(0)
T
7

According to Apache Tutorial:

The include element 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.

According to Wikipedia:

"virtual" specifies the target relative to the domain root, while "file" specifies the path relative to the directory of the current file.

True answered 28/12, 2015 at 0:43 Comment(3)
I get this error. The thing that confuses me is .../assets/reference_editable_forms/js path. that file doesn't exist. [Tue Dec 29 13:28:14 2015] [error] [client ::1] unable to include file "../../include/head.shtml" in parsed file /Applications/MAMP/htdocs/TO/assets/reference_editable_forms/current_employed.html [Tue Dec 29 13:28:14 2015] [error] [client ::1] File does not exist: /Applications/MAMP/htdocs/TO/assets/reference_editable_forms/js, referer: localhost:9988/TO/assets/reference_editable_forms/… ...Galley
A full path of "head.shtml" is "/Applications/MAMP/htdocs/TO/include/head.shtml"?True
Yes. On that machine anyway.Galley
T
1

Server Side Includes are only processed when a file is loaded from a web server, i.e. when you view the web pages in your browser calling them from a URL (like http://.... ). When viewing your web pages on your desktop, you won´t see the includes.

Font: http://www.easywebtutorials.com/tutorials/ssi.html

Tomlin answered 21/7, 2016 at 19:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.