Server Side Includes (SSI)

A simple interpreted server-side scripting language used almost exclusively for the web. It is most useful for including the contents of one or more files into a web page on a web server, using its "#include" directive

This could commonly be a common piece of code throughout a site, such as a page header, a page footer and a navigation menu. SSI also contains control directives for conditional features and directives for calling external programs

For a example, we could use SSI Calls on this web page to call our Blog Navigation links in the left column. This would allow us to make changes to the navigation by changing only 1 file instead of changing hundreds of individual pages. But as it turns out we are actually using PHP calls which work in almost the exact same way
It is supported by Apache, LiteSpeed, nginx, IIS, As well as W3C's Jigsaw, It has its roots in NCSA HTTPd

Related Posts

How do Server Side Includes work?

When someone views your web page, your visitor’s browser sends a request for your HTML page to your Web Server. The server grabs the page, then sees the SSI command (or “call”) and knows that you wanted the Web Server to do something to the HTML file before giving the HTML file to the visitors browser. Because of the way SSI calls work you wil not see the SSI code, only what the SSI call is calling for

posts about hosting

How do I use Server Side Includes on my web site?

Our Web Servers requires that all web pages using SSI calls are named with the ".shtml" extension instead of ".html". Otherwise all of your "Include Calls" will be ignored

What can I use SSI for?

You can "Include” a file into your html document. For example, you have a footer that you would like to show on every page in a web site. You have named the footer filefooter.html. In your main html document (let’s call it index.shtml), you would include this code:
<!--#include virtual="footer.html"-->
It is important to remember the pound sign (#), as that is the key to letting the server that you are using SSI. When your index.shtml is retrieved by a visitor, the Web Server reads your page and sees your call to insert footer.html into your page. The server then retrieves fthe "footer.html" and inserts it exactly where you placed your SSI call.

You can insert your environment variables For example, in your .shtml document, typing
<!--echo var="HTTP_HOST--> returns on this Web Server

Other environment variables that are available and their corresponding output include:
<!--echo var="SERVER_SOFTWARE"--> : Apache/1.3.26 (Unix)
<!--echo var="GATEWAY_INTERFACE"--> : CGI/1.1
<!--echo var="DOCUMENT_ROOT--> : CGI/1.1
<!--echo var="REMOTE_ADDR"--> :
<!--echo var="SERVER_PROTOCOL"--> : HTTP/1.0
<!--echo var="REQUEST_METHOD"--> : GET
<!--echo var="HTTP_USER_AGENT"--> : ia_archiver
<!--echo var="SERVER_NAME"--> :
<!--echo var="SERVER_PORT"--> : 80
<!--echo var="SERVER_ADMIN"--> :

You can insert the file’s last modification date by using
<!--echo var=""LAST_MODIFIED"-->
This is the output of LAST_MODIFIED for this page. You can execute a CGI program. This is highly contingent on your host. When you use this, your script has to be tight and have no security holes. For example, you have a “Quote of the Moment” script, which inserts a new quote every time your page is reloaded. Some people make you go to a specific page to look at your random quotes, but SSI allows you to insert your random quote into any .shtml page

Why I can not Use SSI with .html pages?

Server-Side Includes tend to run slower than regular .html documents because the server looks for SSI commands to parse into the .shtml documents before displaying the page to your visitors. If we had our configuration set to allow SSI parsing in .html documents, server response would be degraded for those users who don’t use SSI. For that reason, we have our server configuration set to SSI-parse only those documents with the .shtml extension

If you want to override the default server configuration so that SSI will work with .html documents, you can create a file named .htaccess and upload it (in ASCII mode) to your main directory. Add the following lines to your .htaccess file:
AddType text/html .html
AddHandler server-parsed .html

If you want both .html and .htm documents to parse SSI, create your .htaccess file with these lines:
AddType text/html .html
AddHandler server-parsed .html
AddHandler server-parsed .htm

Please note that because the server will now look for SSI commands in each .htm page before displaying the page to your visitors, pages with this extension may parse slightly slower (the same speed as normal .shtml files)

Comments, questions or leave a reply
Contact Us

Tweet  Share  Pin  Tumble  Email