Server Side Includes - Usage and examples


Apache Server Side Includes (SSI) can be used add dynamic content to web pages, add JavaScript, reuse HTML code, and more.


Enabling Server Side Includes

For our shared and reseller web hosting accounts, Server-Side Includes are enabled by default for files that have a .shtml extension. However, you may want to use Server-Side Includes with other types of files, such as .html or .htm files.

To do this, create an .htaccess file in your account's document root (public_html) directory, or in the subdirectory where you want to use Server-Side Includes. Add the following text to the .htaccess file:

Options +Includes
AddType text/html .html
AddOutputFilter INCLUDES .html
AddType text/html .htm
AddOutputFilter INCLUDES .htm

These directives demonstrate how to enable Server Side Includes for files that have a .html or .htm extension, but you can easily add other file extension types as well.

Note: It is not possible to use cross-domain or cross account SSI on our servers.


How to use Server-Side-Includes

It's very easy to add your own dynamic content! Here's how:


Reuse HTML

A common use of SSI is to reuse HTML in multiple pages. For example, you want to include HTML code for a header or footer in every page on your web site. You could copy this HTML manually to each page, but what happens when you want to make a change to the footer? You would have to edit each file individually.

SSI provides an easy solution to this problem. Continuing our example, you can create a header.html page that contains the footer code, and then reference the header.html file in your web site pages by using the virtual attribute of SSI: include virtual="header.html".

SSI commands should always be enclosed in the following fashion:

<! --#insert command-- >


  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to make a backup of your website

This section covers choosing what to save, creating backups, storing backups, and restoring your...

.htaccess tutorial

  Part 1 - Introduction In this guide you will find out about the .htaccess file and the power...

HTML - The Basics

  This tutorial includes the following sections: Part 1 - Your First Page Part 2 - Adding...

Uploading files to your website

You can begin uploading files to your hosting account now by using one of two methods: an FTP...

What is PHP?

Short for PHP: Hypertext Preprocessor, an open source, server-side, HTML embedded scripting...