What is Server Side Includes?

Server side includes (SSI) are ways of manipulating web pages at the server level before they are sent to the visitor’s web browser. SSI uses tags so when the information is parsed, it cuts and pastes the information from another source into the webpage. Here’s what happens:

  • The server reads the document and parses it for directives.
  • Follows the instructions (directives) that it finds and merges the results into a final document to deliver to the client's browser
  • The final document is sent to the client browser for viewing.

Why are Server Side Includes Important?

If you have a lot of web pages and want to include information on all of them, this can be a huge asset. Instead of having to update all of your pages, you would just need to update your include file. So let’s say you use SSI for your footer on all your webpages. If you needed to make changes to the footer, you’d only have to update the includes file to do so.

Creating a "Hello World" SSI page

  1. The first step is to log into cPanel. We'll be creating two files for this example. Both files can be created using file manager within cPanel. The first file you will need to create is the helloworld.shtml file. Be sure you name the file with the correct file extension "shtml" or it will not work. 
  2. Once the file is created you'll need to use "code edit" to insert the following code into the file.
  3. <!--#include virtual="helloworld.php?var=Hello%20World" -->

  4. Next, you'll need to create the actual "include" file called "helloworld.php" This file contains the directives to be included in the webpage calling the include file. Make sure both files are in the same location or folder for this example to work. 
  5. <?php
        $variable=$_GET['var'];
        echo $variable;
    ?>
    
    

So now, lets review whats happening during the SSI. The first file you created is including the file called "helloworld.php". The SSI include in our original file sets the variable for the PHP code. The code in the php file that is included tells the webpage to print the variable to the screen.

So as the server reads the initial file and finds that it includes the PHP file we created it loads that. It then parses the code and now knows to "echo" or print the variable defined in the original file based on the SSI. The end result is the variable "hello world" is printed on the screen.

If your SSI is successful you should see something similar to the screen shot below:

SSI-hello-world

If you need further assistance please feel free to contact our support department

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Like this Article?

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

0 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!