SSI Directive
Server-Side Includes (SSI) directives are commands used in web development to include dynamic content or execute server-side scripts within [[HTML]] documents. These directives are processed by the web server before sending the content to the client's browser. SSI directives are typically used to modularize and enhance the functionality of web pages.
- Include Directive (
<!--#include -->
):- Syntax:
<!--#include virtual="file_path" -->
- This directive includes the content of another file into the current HTML document.
- Example:
<!--#include virtual="/includes/header.html" -->
- Syntax:
- Echo Directive (
<!--#echo -->
):- Syntax:
<!--#echo var="variable_name" -->
- This directive displays the value of a specified server variable or environment variable.
- Example:
<!--#echo var="REMOTE_ADDR" -->
- Syntax:
- If Directive (
<!--#if -->
):- Syntax:
<!--#if expr="conditional_expression" --> ... <!--#endif -->
- Allows conditional execution of content based on a specified condition.
- Example:
- Syntax:
<!--#if expr="${QUERY_STRING='show'}" -->
This content is displayed when the 'show' parameter is present in the query string.
<!--#endif -->
- Set Directive (
<!--#set -->
):- Syntax:
<!--#set var="variable_name" value="new_value" -->
- Sets the value of a server variable or environment variable for later use.
- Example:
<!--#set var="my_variable" value="Hello, World!" -->
- Syntax:
- Config Directive (
<!--#config -->
):- Syntax:
<!--#config option="directive_name" value="directive_value" -->
- Configures various settings for SSI processing.
- Example:
<!--#config timefmt="%A, %B %d, %Y" -->
- Syntax:
- Include Virtual Directive (
<!--#include virtual -->
):- Similar to the
include
directive but uses a virtual path instead of a file system path. - Syntax:
<!--#include virtual="/virtual_path/file.html" -->
- Similar to the
- FSize Directive (
<!--#fsize -->
):- Syntax:
<!--#fsize file="file_path" -->
- Displays the size of a specified file.
- Example:
<!--#fsize file="/images/logo.png" -->
- Syntax:
- Flastmod Directive (
<!--#flastmod -->
):- Syntax:
<!--#flastmod file="file_path" -->
- Displays the last modification date of a specified file.
- Example:
<!--#flastmod file="/documents/report.doc" -->
- Syntax: