There is no space between the Example:
This document name
now time
Your IP address
#include demonstration
Action: Inserts the contents of a text file directly into the document page.
Grammar:
The file file name is a relative path that corresponds to the directory where the document using the #include directive resides. The included file can be in the same level of directory or its subdirectories, but not in the previous level directory. File= "nav_head.htm", such as the nav_head.htm document that represents the current directory.
The virtual file name is the full path to the dummy directory on the Web site. For example, the Nav_head.htm file that represents the Hoyi directory under the root directory of the server document; file= "/hoyi/nav_head.htm"
Parameters:
file specifies the location of the containing file relative to this document
virtual Specifies the location relative to the server document root directory
Attention:
- The file name must have an extension.
- The included files can have any file name extensions, and I think it is most convenient to use the HTM extension directly, and Microsoft recommends using the. inc extension (which depends on your hobby).
Example:
Parameters:
file specifies the location of the containing file relative to this document, such as Info.txt, which represents the Info.txt document under the current directory
virtual Specifies the location relative to the server document root directory, as/hoyi/info.txt
Note: The file name must have an extension.
Example:
the news.htm file size in the current directory to the current page
#exec Demonstration
Action: Inserts the output of an external program into the page. You can insert a CGI program or the input of a regular application, depending on whether you use the parameter cmd or CGI.
Grammar:
Parameters:
cmd general application
CGI CGI Script Program
Example:
will display the password file
will display a list of files in the current directory
will execute CGI program gb.cgi.
will execute CGI program access_log.cgi.
Note: As you can see from the example above, this instruction is quite handy, but there are also security issues.
Prohibited method:
- Apache, delete the "options Includes execcgi" code in access.conf;
- In IIS, to disable the #exec command, you can modify the SSIExecDisable metabase;
#config
Role: Specifies the format for error messages, dates, and file sizes returned to the client browser.
Grammar:
Parameters:
errmsg Custom SSI execution error messages can be done for any way you like.
sizefmt File size display, default to byte mode ("bytes") can be changed to kilobytes ("abbrev")
timefmt Time display mode, the most flexible configuration properties.
Example: Displays the size of a file that does not exist
Display file size in kilobytes
Grammar:
Show time in a specific time format
show today is the day of the week, a few months, time zone
Xssi
Xssi (Extended SSI) is a set of advanced SSI instructions that are built into the Apache 1.2 or later Mod-include modules. The available directives are:
#printenv
#set
#if
#printenv
Role: Displays all environment variables that currently exist in the Web server environment.
Grammar:
#set
Function: You can assign a value to a variable for subsequent if statements.
Grammar:
Example:
#if
Function: Create a page that can change the data, which is displayed according to the requirements calculated when using the IF statement.
Grammar:
Display content
Display content
Display content
Example:
Welcome to Http://www.baidu.com
Welcome to Http://www.google.com
Welcome to Afly ' s blog!
Note: The backslash used in the preceding instruction is used to replace the inner quotation marks so that they are not interpreted as an ending expression. Can not be omitted.
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.
timefmt: Defines the use format for dates and times. The TIMEFMT parameter must be used before the echo command.
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.
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.
File: gives the relative path to the current directory, where you cannot use the. /"And you cannot use absolute paths.
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.
Document_uri: Displays the virtual path of the current document. For example:
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
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:
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:
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:
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.
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:
SERVER_NAME: Displays the server's host name, DNS alias, or IP address. For example:
Server_protocol: Displays the protocol name and version used by the client request, such as http/1.0. For example:
Server_port: Displays the server's response port. For example:
Request_method: Displays the client's document request methods, including get, head, and post. For example:
Remote_host: Displays the name of the client host that sent the request information.
REMOTE_ADDR: Displays the client IP address that sent the request information.
Auth_type: The authentication method that displays the user's identity.
Remote_user: Displays the account name used by the user accessing the protected page.
4, Fsize: Display the size of the specified file, you can combine the config command sizefmt parameters to customize the output format.
5, Flastmod: Display the last modified date of the specified file, you can combine the config command timefmt parameters to control the output format.
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:
File
another file
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:
About the difference between shtml and HTML
Let's take a look at the difference between SHTML and HTML, if you explain it in one sentence: SHTML is not HTML but a server api,shtml is the dynamically produced HTML of the server.
While both are hypertext formats, shtml is a file for SSI technology. That is, the server Side Include--ssi contains instructions. If the Web server has SSI capabilities, most, especially unix-based platform-based Web servers, such as Netscape Enterprise Server, support SSI commands.