Tuesday, October 11, 2016

What is SSI server side Include

SSI server side include

It is a technique of serving dynamic content to the web page without

modifying  content in the multiple files .Here you can insert content

into 1 file into other files. suppose you have a website comprising

of multiple pages containg header and footer . You define a file name

header.html and footer.html in every web page using #include . You

need not have to change header footer in every webpage if any

modifications needs to be done . Just change in the header.html and

footer.html and it will be automatically changed throughout the

website where ever its #include . SSI can be said as it is typically

used as directive inside HTML tags .

Header.html

<header>
  <h1> The SSI Header</h1>
  <img  href="./images/logo.png"  alt="Logo" />
</header>

footer.html

<footer>
  <span> The SSI footer, Los Angeles, USA <span>
  <ul>
  <li> <a href="aboutus.html">About Us</a> </li>
  <li> <a href="contactus.html">Contact Us</a> </li>
  <li> <a href="ourworks.html">Portfolio</a> </li>
  </ul>
</footer>


Index.html

<html>
  <head>
  <title>The SSI main Page</title>
  </head>
  <body>
  <!--#include virtual="header.html" -->
   <div>
      <!-- Page content goes here   -->
   </div>
  <!--#include virtual="footer.html" -->
  </body>
</html>

This explains how you can reuse your Html script .

some commonly used SSI directives are :-

1. include [file or virtual]

<!--#include file="footer.html" -->

2. exec [cgi or cmd]

<!--#exec cgi="/cgi-bin/foo.cgi" -->
<!--#exec cmd="ls -l" -->

3. echo [var]

<!--#echo var="REMOTE_ADDR" -->

4. config [timefmt,sizefmt,errmsg]

<!--#config timefmt="%y %m %d" -->
<!--#config sizefmt="bytes" -->
<!--#config errmsg="SSI command failed!" -->

5. printenv

<!--#printenv -->