Enabling Server-Side Includes
On our shared servers, 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:Using Server-Side Includes
You can use Apache Server-Side Includes in a variety of scenarios. The following sections are a brief introduction to some possibilities using SSI. For a detailed discussion of SSI capabilities, please see the More Information section below.Displaying a page modification timestamp
One of the most common visible uses of SSI is displaying when a page was last modified. The following HTML snippet demonstrates one way to do this:Reusing HTML
Another common use of SSI is reusing HTML (such as for a header or footer) in multiple pages. For example, you may have HTML code for a footer that you want to include 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 footer.html page that contains the footer code, and then reference the footer.html file in your web site pages by using the following HTML snippet:Using conditional expressions
You can use conditional expressions in SSI to add basic flow control to your web pages. These conditional expressions work similarly to conditional statements in other programming languages. For example, the following HTML snippet demonstrates how to display different text based on the current date:More information
- To view the official online Apache documentation for Server-Side Includes, please visit https://httpd.apache.org/docs/current/mod/mod_include.html.
- To view a more in-depth tutorial for Server-Side Includes, please visit https://httpd.apache.org/docs/trunk/howto/ssi.html.