SSI (Server Side Include), is often referred to as server-side embedding, is a server-based web-based web-based technology similar to ASP. Most of the WEB servers based on UNIX platforms, such as Netscape Enterprise Server, supports SSI commands.
SSI work principle:
In a SSI file that is usually .SHTML, the standard HTML encoding will be sent directly to the browser, and the SSI command in the embedded Perl language is first explained by the web server, if it is the standard output, The output information will also be sent to the browser as a standard HTML.
SSI simple application example:
We found that HTML in the document is directly transmitted to the client, and the SSI command is executed. The SSI code is invisible at the client, and the client can only see the effect it performs.
A more practical example
One problem that the website maintenance often encounters is that the structure of the website has been fixed, but it has to be a large number of web pages in order to update some content. SSI provides a simple and effective way to solve this problem. It places the basic structure of a website in several simple HTML files (templates), which will only pass text to the server in the future, let the program Automatically generate a web page according to the template to make the management large site easier. Such as:
< P> News update Date: body> html>
Place frequent updates in News.txt, SSI will contain its contents into the output web page via the include instruction. The latest change date of New.txt can be displayed in the web page via the FLASTMOD instruction.
Construct the environment of learning SSI
Support for SSI's Web Server, such as Omnihttpd Professional, this is a web server that supports SSI's WIN 95/98 platform. You can download this shared software directly from http://www.omnicron.ab.ca/httpd/. # Echo
Role: Insert environment variables into the page. Syntax: Example: This document name: Today: Your IP address is: Variables used in SSI: 1. Only variables that can be used in SSI. 2. Standard CGI variable 3. Some servers supported variables 1 below is the variables supported by standard SSI: Variable Name Scheme 1 Document_name Current Document Name Echo.html 2 Document_URL or Document_uri Current Document Relative to URL /ssi/echo.html 3 Query_String_unescape or query_string sent by query String Sample 4 Date_local Server Current Date Sun, 23 May 1999 21:54:30 5 Date_GMT Server Time Set by Greenwich Time Sun, 23 May 1999 13:54:30 6 Last_Modified current document last modified time 23-May -1999 PST 2 Standard CGI Variable Web About CGI Environment Variable Test: Linux Under Apache: http: //hoyi.zb169.net/cgi-bin/hiecho.ci? SampleFreebsd Under Apache: http: // hoyi. OnlineExpress.net/cgi-bin/hiecho.ci?sample CGI Environment Variable Name Scheme 1 Authentication Type 2 Content_Type User 2 Content_Length Server Output Text Length 0 3 HTTP_ACCEPT Client Acceptable MIME Type Application / VND.MS- Excel, Application / MSWORD, * / * 4 http_user_agent client browser configuration status mozilla / 4.0 (compatible; msie 4.01; windows 98) 5 GateWary_Interface server CGI / 1.1 6 Path_info client gives additional Path Information 7 Path_Translated Path_info value, but with virtual path / v / spool / webadm / html 8 query_string with an extension to a directory specification, in the URL that references this script, follow the question mark (?) Sample 9 Remote_Addr Customer Machine IP address 202.103.27.103 10 Remote_host client name 11 Request_method HTTP request method GET 12 script_na Me Current Script Name / CGI-MAIN/CGIWRAP/HOYI/HIECHO.CGI 13 Server_name server name or IP address hoyi.zb169.net 14 Server_Port server connection TCP / IP port 80 15 Server_Protocol and request information Retrieval agreement name With versions, usually http / 1.0 http / 1.1 16 Server_software response requests Web server software name and version apache / 1.3.6 (unix) 2, # include: Plug the content of text files directly into the document page.
Syntax: file file name is a relative path, the path relative to documentation using the #include instruction The directory where you are located. The included files can be in the same level directory or their subdirectories, but cannot be in the previous directory. As indicating the NAV_HEAD.htm document in the current directory, File = "NAV_HEAD.HTM". The Virtual file name is the full path to the virtual directory on the Web site. As indicating the NAV_HEAD.htm file under the HOYI directory relative to the server document; the file = "/ hoyi / nav_head.htm" parameter: file specifies that the location Virtual specified by the file relative to this document is specified relative to the server document root directory. Location Note: 1. The file name must have an extension. 2. The file being included can have any file extensions. I feel that I use the HTM extension directly, Microsoft recommends using the .inc extension (this will look at your hobby). Example: Plug the header file into the current page Insert the tail file into the current page 2, #include Role: Insert the content of the text file directly into the document page. Syntax: file file name is a relative path, the path relative to documentation using the #include instruction The directory where you are located. The included files can be in the same level directory or their subdirectories, but cannot be in the previous directory. As indicating the NAV_HEAD.htm document in the current directory, File = "NAV_HEAD.HTM". The Virtual file name is the full path to the virtual directory on the Web site. As indicating the NAV_HEAD.htm file under the HOYI directory relative to the server document; the file = "/ hoyi / nav_head.htm" parameter: file specifies that the location Virtual specified by the file relative to this document is specified relative to the server document root directory. Location Note: 1. The file name must have an extension. 2. The file being included can have any file extensions. I feel that I use the HTM extension directly, Microsoft recommends using the .inc extension (this will look at your hobby). Example: Insert the header file into the current page Insert the tail file into the current page 4. #exec effect: Insert an output of an external program into the page. You can insert the CGI program or the input of the regular application, depending on the parameter used is CMD or CGI. Syntax: Grammar: Parameters: CMD General App CGI CGI Script Program: The password file will be displayed will display the current directory list will execute the CGI program GB.cgi.
will execute the CGI program access_log.cgi. Note: From the example above, this instruction is quite convenient, but there is also a security problem. Prohibited method:. Apache deletes the line code of "Options Includes Execcgi" in Access.conf; In IIS, to disable the #exec command, modify the ssiexecdisable metadata; 5. # config: Specifies the format of the error message, date, and file size that returns to the client browser. Syntax: parameter : Errmsg Custom SSI executes error messages, you can do anything you like. Sizefmt file size display mode, the default is byte mode ("Bytes") can be changed to the kilobyte mode ("Abbrev") Timefmt time display mode, the most flexible configuration properties.
Code sample action code example effect% a mon Abbreviated week a few% M 05 months% a Monday a few% M 55 vs% b% h AUG abbreviation Month name% P AM, afternoon (AM or PM)% R 10 : 20: 20 AM 12 small time% b Auguest month name% s 40 second% d 01 the third day of the month in the first few days% T 20:20:30 24 small time% d 05/28/99 Digital Date% U% W 21 Weekly per year, per year, the day, no 0% W 2 from Sunday to Today,% h 20 hours (24-hour)% y 99 2 digits format year% i 08 hours (12 hours) System Y999 4-digit Number% J 320 One Number of Day% Z PDT Time Zone Position Code Example Role Code Example M Mon Abbreviation Week Men M 05 Month A MONDAY Week 55% B% h aug abbreviation monthly name% P AM, afternoon (AM or PM)% r 10:20:20 AM 12 small time% b Auguest month name% s 40 second% d 01 the first day % T 20:20:30 24 small time% d 05/28/99 Digital Date% U% W 21 Week to Week in the year E 1 in the first few days, no 0% W 2 from Sunday to today H 20 hours (24-hour)% y 99 2 digit number% i 08 hours (12-hour system)% Y 1999 4-digit representation annual% J 320 day% z PDT time zone position Example: Show a size Display file size in a specific time format Time Show Today is a day, a few months, time zone 6.xssi XSSI (Extended SSI) is a set of advanced SSI instructions, built in Apache 1.2 or higher Modular MOD-INCLUDE module in. Among them, the instructions are: #printenv #set #if #printenv effect: Displays all environment variables currently existing in the web server environment. Syntax: Parameters: Non-Example: #set effect: You can assign a variable to use for later IF statements. Syntax: parameter: Non-sample: #IF role : Creating a page that can change the data, which is displayed according to the requirements calculated when using the IF statement.
Syntax: Display content Display content Display content Parameters: About XSSI Condition Expression Expression (String) If String exists, return true string1 = string2 If Two strings are equal, return true string1! = String2 If the two strings do not wait, return true string1