Server Side Includes
- A server-side include is a coding that you can include within your HTML document that will tell the web server to include other information with the document being served.
- Server side includes are a handy way to include information on your pages automatically. For example, you can use an #INCLUDE statement to display the header and footer of your pages automatically and make sure that each page displays the same information. You can save time by using a single header.html or footer.html file if this information changes. You can also use server side includes for graphics such as logos or image maps that should appear on multiple pages.
- You will need to use the .shtml extension for pages using the server side include (those that have #INCLUDE statements) for accounts hosted on Webserve. The file that is being included can have other extensions, such as .html.
- Please note that for security reasons, the EXEC server side include is NOT enabled on Webserve. The EXEC command is often used to run a cgi or perl program from a web page, but this function is not enabled on Webserve.
Using Server Side Includes with files in the same directory
To use a server side include, use the #include statement. This command tells the server to include another file, and tells it the file name that should be included:
This page uses server side includes to display the Webmaster banner and header information. An example of the command used is:
<!--#include file="header.html" -->
In this example it is placed in the body of the document, immediately after the <BODY> tag. One thing about SSI includes is the process of including. It takes two separate files and creates one whole file. What the server does is actually to take the SSI page and physically inserted it into the page calling it.
Using Server Side Includes with files located in different directories
If the server-side include calls a file that is located in another directory in the account, you need to make some modifications. For example:
<!--#include virtual="../header.html" -->
In the above example, the file named "header.html" is located in the directory above the location of the file referencing it. Also, instead of using "#include file" you must use the command "#include virtual".
The footer for this page is created dynamically, so that the date that the file was last modified automatically appears in the footer. The server side include statement calls another .shtml file, using this code:
The footer statement on this page is placed at the bottom of the file, just before the </BODY> tag.<!--#include file="footer.shtml"-->
For more information on how to use SSI on Webserve, please see our SSI Tutorial Document.