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 .shtml and 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

  • SSI directives begin with <!--# and end with -->.

  • Ensure your server has mod_include enabled (Ruachost servers support this).

  • SSI is processed on the server, unlike JavaScript which runs on the client.

  • Overuse of SSI can affect performance; use for lightweight tasks.

آیا این پاسخ به شما کمک کرد؟ 0 کاربر این را مفید یافتند (0 نظرات)

Powered by WHMCompleteSolution