Server‑Side Includes (SSI) allow you to embed dynamic content into your web pages. On ruachost.com, SSI is supported on Apache servers and can be enabled through .htaccess directives or by using .shtml files.
Why Use SSI?
-
Reuse common HTML code (headers, footers, menus).
-
Display dynamic information (last modified date, environment variables).
-
Add conditional logic to web pages.
-
Simplify site maintenance by centralizing shared content.
Enabling SSI
Method 1: Use .shtml Files
-
By default, SSI is enabled for files ending in
.shtml. -
Rename your HTML file to
.shtmland insert SSI directives.
Method 2: Enable SSI for .html or .htm Files
Add the following to your .htaccess file:
Options +Includes
AddType text/html .html
AddOutputFilter INCLUDES .html
AddType text/html .htm
AddOutputFilter INCLUDES .htm
Common SSI Directives
1. Display Last Modified Date
<p><em>Page last modified on <!--#echo var="LAST_MODIFIED" --></em></p>
2. Reuse HTML Code (e.g., Footer)
<!--#include virtual="footer.html" -->
3. Conditional Expressions
<!--#if expr="$DATE_LOCAL = /^Saturday/ || $DATE_LOCAL = /^Sunday/" -->
<p>It's the weekend!</p>
<!--#else -->
<p>It's not the weekend...</p>
<!--#endif -->
Important Notes
|