2. the Include command can insert text or images from other documents into the currently parsed documents, which is the key to the whole SSI. By using the Include command, you only need to change one file to instantly update the entire site! The Include command has two different parameters. if SyntaxHighlighter. al is used incorrectly
2. Include command
The Include command inserts text or images from other documents into the parsed documents, which is the key to the whole SSI. By using the Include command, you only need to change one file to instantly update the entire site!
The Include command has two different parameters. If an incorrect parameter is used to update the site, not only does not meet the original intention, but will get a lot of error information.
Virtual:Provides a virtual path to a document on the server. For example:
$ # @ 60 ;! -- # Include virtual = "/includes/header.html" -- $ # @ 62;
To organize site content more rationally, you can create the "des" subdirectory under the root directory to store all the contained files. The Virtual parameter notifies the server that it contains a Virtual file, that is, the file and the file being parsed are not in the same directory, but stored in other directories. The server finds the des sub-directory under the root directory based on the value of this parameter. In this way, you can put all the files contained in HTML documents in one directory, and store different pages in different directories or subdirectories according to their relationships. No matter which document is parsed by the server, you can find the contained file without any errors.
However, there is a small problem to solve. Generally, we add some TITLE and META tags to the page. if we require that all pages call the same header file, it is not flexible. When you encounter such a problem, you can use two files that contain the TITLE tag, one for the content before the TITLE tag, and the other for the part after the META tag, you can add any custom content between two contained files. For example:
$ # @ 60 ;! -- # Include virtual = "/includes/header1.html" -- $ # @ 62;
$ # @ 60; TITLE $ # @ 62; Your Page Title $ # @ 60;/TITLE $ # @ 62;
$ # @ 60; LINK rel = STYLESHEET href = "http://domain.com/styles/my.css" Type = "text/css" $ # @ 62;
$ # @ 60; meta name = "Description" CONTENT = "Description of page" $ # @ 62;
$ # @ 60; meta name = "Keywords" CONTENT = "keywords for page" $ # @ 62;
$ # @ 60 ;! -- # Include virtual = "/includes/header2.html" -- $ # @ 62;
Place the page content here
$ # @ 60 ;! -- # Include virtual = "/includes/footer.html" -- $ # @ 62;
We can see that adding headers and footers to a page can greatly reduce the workload of site updates. But what if we want to dynamically display some content, such as the last update time of the page? You can save the included files with the suffix ".html" so that you can call other included files in the included files.
File: Give? The relative path of the current directory, where "../" cannot be used or an absolute path. For example:
$ # @ 60 ;! -- # Include file = "header.html" -- $ # @ 62;
In this case, each directory contains a header.html file. Of course, using this method is not much easier than updating each page, but it is very convenient if you only update one or two files. For example, if we don't want a person who is not familiar with HTML to directly modify the news page on the website, we can just ask him to update a separate text file, then, the file will be included in the HMTL document, so that the original page will not be damaged and the content will be updated at the same time.
3. Echo:
The Echo command displays the following environment variables:
DOCUMENT_NAME: Displays the name of the current document.
$ # @ 60 ;! -- # Echo var = "DOCUMENT_NAME" -- $ # @ 62;
The result is as follows:
Index.html
DOCUMENT_URI: Displays the virtual path of the current document. For example:
$ # @ 60 ;! -- # Echo var = "DOCUMENT_URI" -- $ # @ 62;
The result is as follows:
/YourDirectory/YourFilename.html
With the continuous development of websites, those longer and longer URLs will be a headache. If SSI is used, everything will be solved. Because we can combine the website domain name with the SSI command to display the complete URL, that is:
Http: // YourDomain $ # @ 60 ;! -- # Echo var = "DOCUMENT_URI" -- $ # @ 62;
QUERY_STRING_UNESCAPED: Displays the query strings sent by the client without escaping. all special characters are preceded by the escape character "". For example:
$ # @ 60 ;! -- # Echo var = "QUERY_STRING_UNESCAPED" -- $ # @ 62;
DATE_LOCAL: Display the date and time when the server sets the time zone. You can combine the timefmt parameter of the config command to customize the output information. For example:
$ # @ 60 ;! -- # Config timefmt = "% A, the % d of % B, in the year % Y" -- $ # @ 62;
$ # @ 60 ;! -- # Echo var = "DATE_LOCAL" -- $ # @ 62;
The result is as follows:
Saturday, the 15 of each L, in the year 2000
There are two pages in this news. Currently, there are two pages in page 1st.
DATE_GMT: The function is the same as that of DATE_LOCAL, except that the returned date is based on the Greenwich Mean Time. For example:
$ # @ 60 ;! -- # Echo var = "DATE_GMT" -- $ # @ 62;
LAST_MODIFIED: Displays the last update time of the current document. Similarly, this is a very real rose capsule in SSI. why? Gray ?? The following simple text is added to the TML document to dynamically display the update time on the page.
$ # @ 60 ;! -- # Echo var = "LAST_MODIFIED" -- $ # @ 62;
CGI environment variable
In addition to SSI environment variables, the echo command can also display the following CGI environment variables:
SERVER_SOFTWARE: Displays the name and version of the server software. For example:
$ # @ 60 ;! -- # Echo var = "SERVER_SOFTWARE" -- $ # @ 62;
SERVER_NAME: Displays the host name, DNS alias, or IP address of the server. For example:
$ # @ 60 ;! -- # Echo var = "SERVER_NAME" -- $ # @ 62;
SERVER_PROTOCOL: Display the protocol name and version used by the client request, such as HTTP/1.0. For example:
$ # @ 60 ;! -- # Echo var = "SERVER_PROTOCOL" -- $ # @ 62;
SERVER_PORT: Display the server's response port. For example:
$ # @ 60 ;! -- # Echo var = "SERVER_PORT" -- $ # @ 62;
REQUEST_METHOD: Display the client's document request methods, including GET, HEAD, and POST. For example:
$ # @ 60 ;! -- # Echo var = "REQUEST_METHOD" -- $ # @ 62;
REMOTE_HOST: Displays the name of the client host that sends the request information.
$ # @ 60 ;! -- # Echo var = "REMOTE_HOST" -- $ # @ 62;
REMOTE_ADDR: Displays the IP address of the client sending the request.
$ # @ 60 ;! -- # Echo var = "REMOTE_ADDR" -- $ # @ 62;
AUTH_TYPE: Display the authentication method for user identity.
$ # @ 60 ;! -- # Echo var = "AUTH_TYPE" -- $ # @ 62;
REMOTE_USER: Displays the account name used by the user accessing the protected page.
$ # @ 60 ;! -- # Echo var = "REMOTE_USER" -- $ # @ 62;
4. Fsize:Display the size of the specified file. you can use the sizefmt parameter of the config command to customize the output format.
$ # @ 60 ;! -- # Fsize file = "index_working.html" -- $ # @ 62;
5. Flastmod: Display the last modification date of the specified file. you can control the output format with the timefmt parameter of the config command.
$ # @ 60 ;! -- # Config timefmt = "% A, the % d of % B, in the year % Y" -- $ # @ 62;
$ # @ 60 ;! -- # Flastmod file = "file.html" -- $ # @ 62;
Here, we can use the flastmod parameter to display the update dates of all links on a page. The method is as follows:
$ # @ 60 ;! -- # Config timefmt = "% B % d, % Y" -- $ # @ 62;
$ # @ 60; a href = "/directory/file.html" $ # @ 62; File $ # @ 60;/A $ # @ 62;
$ # @ 60 ;! -- # Flastmod virtual = "/directory/file.html" -- $ # @ 62;
$ # @ 60; a href = "/another_directory/another_file.html" $ # @ 62; Another File $ # @ 60;/A $ # @ 62;
$ # @ 60 ;! -- # Flastmod virtual = "/another_directory/another_file.html" -- $ # @ 62;
The result is as follows:
File transfer L 19,200 0
Another File January 08,200 0
Some readers may think that the two links are so complicated and inconvenient at all. In fact, if there are 20 or more links on the page, and each link is updated on a regular basis, we can see that the purpose of using flastmod to display the date of modification.
6. Exec
The Exec command can execute CGI scripts or shell commands. The usage is as follows:
Cmd: Use/bin/sh to execute the specified string. If SSI uses the IncludesNOEXEC option, the command will be blocked.
Cgi: It can be used to execute CGI scripts. For example, in the following example, the counter. pl script under the cgi-bin directory on the server is used to place a counter on each page:
$ # @ 60 ;! -- # Exec cgi = "/cgi-bin/counter. pl" -- $ # @ 62;
There are two pages in this news. Currently, there are two pages in page 2nd.