Difference between revisions of "Content:Virtual versus File Include"
(New page: Both <code>include virtual</code> and <code>include file</code> are examples of server side includes (SSIs). When the webserver is serving a page to a client, and it sees an include, it t...) |
(→Include File) |
||
(One intermediate revision by the same user not shown) | |||
Line 11: | Line 11: | ||
=== Include Virtual === | === Include Virtual === | ||
When including a virtual, specify it from the webroot, that is, the "virtual filesystem" that the website resides on. Because of this, it is impossible to access files outside of the web document tree. | When including a virtual, specify it from the webroot, that is, the "virtual filesystem" that the website resides on. Because of this, it is impossible to access files outside of the web document tree. | ||
+ | |||
+ | This also means that the path will be standardizes for all of the includes, which is nice for keeping the code clean. This also means that the page can be moved, and will always still find the include correctly. | ||
=== Include File === | === Include File === | ||
When including a file, specify the path from the directory where the parent page resides. | When including a file, specify the path from the directory where the parent page resides. | ||
+ | |||
+ | Because it is relative to the page's position, if the parent page is moved to a different directory inside the webroot, the include's path will have to be updated by hand. |
Latest revision as of 11:50, 3 April 2009
Both include virtual
and include file
are examples of server side includes (SSIs). When the webserver is serving a page to a client, and it sees an include, it takes the code from the included file and "pastes" it into the file that it's serving. The only difference between the two is how you specify the path to the file.
They look something like this:
<!-- #include virtual="/includes/header.html" --> or <!-- #include file="../../includes/header.html" -->
Include Virtual
When including a virtual, specify it from the webroot, that is, the "virtual filesystem" that the website resides on. Because of this, it is impossible to access files outside of the web document tree.
This also means that the path will be standardizes for all of the includes, which is nice for keeping the code clean. This also means that the page can be moved, and will always still find the include correctly.
Include File
When including a file, specify the path from the directory where the parent page resides.
Because it is relative to the page's position, if the parent page is moved to a different directory inside the webroot, the include's path will have to be updated by hand.