php include from a different directory

Avatar
  • Answered
To make use of a SSI, something like the following needs to be used: This means the include is in the same folder as the page in which it is to be included. However, if I want to include something from the root directory into a file in a sub-directory, how would that work? I have tried the following without success: Any ideas?
Avatar
Arn
Hello Vmsmusic, Thanks for the question! In terms of "include virtual" we found this article on Server Side Includes on Wikipedia that should hopefully give you the answer you need:

If the process does not have access to read the file or execute the script, the include will fail. "virtual" specifies the target relative to the domain root, while "file" specifies the path relative to the directory of the current file. When using "file" it is forbidden to reference to absolute paths. Higher directories (..) are usually forbidden, unless explicitly configured. The Apache documentation recommends using "virtual" in preference to "file".

When you need to reference the file in a subdirectory, then you would use FILE instead of VIRTUAL. I hope that helps! Please let us know if you require any further assistance. Regards, Arnel C.