SSI usage details (2)

Source: Internet
Author: User
Tags config echo command file size

Here we will introduce each of them.

1. config command

The config command is primarily used to modify the default settings for SSI. which

ErrMsg: Sets the default error message. In order to return the user-defined error message normally, the errmsg parameter must be placed in front of the other SSI commands in the HTML file, otherwise the client can only display the default error message, not the custom information set by the user.

    <!--#config errmsg="Error! Please email webmaster@mydomain.com -->

TIMEFMT: Defines the use format for dates and times. The TIMEFMT parameter must be used before the echo command.

    <!--#config timefmt="%A, %B %d, %Y"-->
    <!--#echo var="LAST_MODIFIED" -->

Display results as:

    Wednesday, April 12, 2000

Perhaps the user is unfamiliar with the%a%B%d used in the previous example, so let's summarize some of the more commonly used date and time formats in SSI in tabular form.

SIZEFMT: Determines whether the file size is expressed in bytes, kilobytes, or megabytes. If the parameter value is "bytes" in bytes, the abbreviation can be used for kilobytes and megabytes. Similarly, the SIZEFMT parameter must be placed in front of the fsize command before it can be used.

    <!--#config sizefmt="bytes" -->
    <!--#fsize file="index.html" -->

2. Include command

The Include command inserts text or pictures from other documents into the currently parsed document, which is the key to the entire SSI. You can update the entire site in an instant by simply changing one file with the Include command!

The include command has two different parameters:

Virtual: gives a dummy path to a document on the server side. For example:

    <!--#include virtual="/includes/header.html" -->

File: Gives the relative path to the current directory, where you cannot use the. /"And you cannot use absolute paths. For example:

    <!--#include file="header.html" -->

This requires a header.html file to be included in each directory.

3. Echo command

The echo command can display the following environment variables:

Document_name: Displays the name of the current document.

    <!--#echo var="DOCUMENT_NAME" -->

Display results as:

Index.html

Document_uri: Displays the virtual path of the current document. For example:

    <!--#echo var="DOCUMENT_URI" -->

Display results as:

    /YourDirectory/YourFilename.html

With the development of the Web site, the increasingly long URL address will certainly make people headache. If you use SSI, everything will be solved. Because we can combine the domain name of the website with the SSI command to display the complete URL, namely:

  http://YourDomain<!--#echo var="DOCUMENT_URI" -->

Query_string_unescaped: Displays the query string sent by the client without escaping processing, where all the special characters are preceded by an escape character "\". For example:

  <!--#echo var="QUERY_STRING_UNESCAPED" -->

Date_local: Displays the date and time the server set the time zone. The user can combine the timefmt parameters of the config command to customize the output information. For example:

  <!--#config timefmt="%A, the %d of %B, in the year %Y" -->
 <!--#echo var="DATE_LOCAL" -->

Display results as:

  Saturday, the 15 of April, in the year 2000

DATE_GMT: The function is the same as date_local, except that it returns a date based on Greenwich Mean time. For example:

  <!--#echo var="DATE_GMT" -->

Last_modified: Displays the last update time for the current document. Again, this is a very useful feature of SSI, as long as you add the following simple text to the HTML document, you can dynamically display the update time on the page.

  <!--#echo var="LAST_MODIFIED" -->

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.