SSI use Details (ii)

Source: Internet
Author: User
Tags date format file size header include variables string version
Detailed below we will introduce each.

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 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"-->

CGI Environment variables

In addition to the SSI environment variables, the echo command can display the following CGI environment variables:

Server_software: Displays the name and version of the Server software. For example:
<!--#echo var= "Server_software"-->
SERVER_NAME: Displays the server's host name, DNS alias, or IP address. For example:
<!--#echo var= "SERVER_NAME"-->
Server_protocol: Displays the protocol name and version used by the client request, such as http/1.0. For example:
<!--#echo var= "Server_protocol"-->
Server_port: Displays the server's response port. For example:
<!--#echo var= "Server_port"-->
Request_method: Displays the client's document request methods, including get, head, and post. For example:
<!--#echo var= "Request_method"-->
Remote_host: Displays the name of the client host that sent the request information.
<!--#echo var= "Remote_host"-->
REMOTE_ADDR: Displays the client IP address that sent the request information.
<!--#echo var= "REMOTE_ADDR"-->
Auth_type: The authentication method that displays the user's identity.
<!--#echo var= "Auth_type"-->
Remote_user: Displays the account name used by the user accessing the protected page.
<!--#echo var= "Remote_user"-->
4, Fsize: Display the size of the specified file, you can combine the config command sizefmt parameters to customize the output format.

<!--#fsize file= "index_working.html"-->

5, Flastmod: Display the last modified date of the specified file, you can combine the config command timefmt parameters to control the output format.

<!--#config timefmt= "%A, the%d of%B, in the year%Y"-->
<!--#flastmod file= "file.html"-->

Here, we can use the Flastmod parameter to display the updated date of all the linked pages on a page. The method is as follows:

<!--#config timefmt= "%B%d,%Y"-->
<a href= "/directory/file.html" >File</A>
<!--#flastmod virtual= "/directory/file.html"-->
<a href= "/another_directory/another_file.html" >another file</a>
<!--#flastmod virtual= "/another_directory/another_file.html"-->
Display results as:
File April 19, 2000
Another File January 08, 2000

6, Exec

The EXEC command can execute CGI scripts or shell commands. Use the following methods:

CMD: Executes the specified string using/bin/sh. If SSI uses the INCLUDESNOEXEC option, the command is masked.

CGI: can be used to execute CGI scripts. For example, the following example uses the counter.pl script program in the server-side Cgi-bin directory to place a counter on each page:

<!--#exec cgi= "/cgi-bin/counter.pl"-->

< finished full >


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.