In the shtml tutorial, what is the HTML file extension used by shtml to use SSI (Server Side Include)? SSI (Server Side Include) is usually called "server side embed" or "server side include ", is a server-based web page creation technology similar to ASP. How SSI works: before sending content to a browser, you can use the "server-side inclusion (SSI)" command to include text, graphics, or application information to a webpage. For example, you can use SSI to include a time/date stamp, a copyright statement, or a form for the customer to fill in and return. For text or graphics that repeatedly appear in multiple files, using include files is a simple method. You can store the content in an contained file without entering the content into all files. You can use a very simple statement to call the inclusion file, which instructs the Web server to insert content into an appropriate webpage. In addition, when a file is included, all changes to the content can be completed in one place. Because files containing SSI commands require special processing, the SSI file extension must be assigned to all SSI files. The default extensions are. stm,. shtm, And. shtml. The Web server processes SSI commands while processing webpages. When the Web server encounters an SSI command, it directly inserts the content containing the file into the HTML webpage. If the "include file" contains the SSI command, insert the file at the same time. In addition to the basic commands used to include files, you can also use the SSI command to insert information about files (such as the file size) or run applications or shell commands. A common problem with website maintenance is that the website structure is fixed, but a large number of webpages have to be redone to update a little content. SSI provides a simple and effective method to solve this problem. It places the basic structure of a website in several simple HTML files (templates ), in the future, all we need to do is to upload text to the server so that the program can automatically generate webpages according to the template, making it easy to manage large websites. Therefore, the purpose of pages in shtml format is similar to that of ASP, but it is faster and more efficient because it is an API. It is faster than ASP and slower than HTML. However, because it can be included on the server, therefore, it is easy to update pages (especially batch update banner and copyright). Imagine that you have an HTML section that involves inserting some special server scripts, such as inserting other HTML sections, you choose ASP to complete this task, but if the task is more heavy, need more time, such as 5 S, this time you do not need ASP and use shtml, maybe the processing time is only 4S. What is SSI used? The reason we need to talk about SSI is the acronyms of shtml-server-parsed HTML. Contains HTML text containing commands on the embedded server. Before being sent to a browser, the server will completely read, analyze, and modify the shtml document. Shtml is similar to ASP. Some SSI commands are used in files named after shtml, just like ASP commands. You can write ssi commands in the shtml file, when the client accesses these SHTML files, the server will read and interpret these SHTML files and explain the SSI commands contained in The shtml files, for example: you can use the SSI command in the shtml file to reference other HTML files (# include). The files sent by the server to the client are interpreted as shtml without the SSI command. It implements a function not available in HTML, that is, it can implement a dynamic shtml. It can be said that it is an evolution of HTML. Like Sina's news system, the news content is fixed, but the advertisements and menus on it are referenced by # include. At present, it mainly has the following usage: display Server Environment Variables <# echo> insert text content directly to the document <# include> display Web Document Information <# flastmod # fsize> (such as file creation date/size)) directly execute various programs on the server <# exec> (for example, CGI or other executable programs) and set the SSI information display format <# config> (for example, the file creation date/size display mode) advanced SSI <xssi> allows you to set variables to use the if Condition Statement. Ssissi is a set of commands provided for Web servers. These commands can be embedded directly into the comments of HTML documents. Example: <! -- # Include file = "info.htm" --> is an SSI command, which serves to bring the content of "info.htm" to the front page. When a visitor visits the page, the HTML file displays the content of info.htm. The usage of other SSI commands is similar to the previous example. It can be seen that SSI only inserts a little code, and the usage is very simple. Of course, if the web server does not support SSI, it simply uses it as a comment and directly skips the content. The browser also ignores this information. How can I configure the SSI function on my web server? On some Web servers (such as IIS 4.0/Sambar 4.2), files containing the # include command must use extensions that have been mapped to the SSI interpreter; otherwise, the web server will not process the SSI command; by default, the extension. STM ,. SHTM and. shtml is mapped to the interpreter (ssinc. DLL ). Apache changes SRM based on your settings. conf example: addtype text/X-server-parsed-HTML. shtml parses only files with the .shtml extension SSI command addtype text/X-server-parsed-HTML. HTML parses all HTML documents. ssi commands. The Netscape Web server directly uses the Administration Server to enable the SSI function. Website uses the mapping label in the server admin program, the extension to add content type: wwwserver/html-ssicern server does not support SSI, available SSI fraud method, download a Perl script to the http://sw.cse.bris.ac.uk/WebTools/fakessi.html, this allows your CERN server to use some SSI commands. (Exec commands are not supported .) SSI command basic format program code: <! -- Command name = "command parameter"> example: <! -- # Include file = "info.htm" --> Note: <! --> Indicates the annotation in HTML syntax. This information is ignored when the web server does not support ssi. # Include is one of the SSI commands. File is the include parameter, and info.htm is the parameter value. In this command, specify the document name to be included. Note: <! -- There is no space between the and #, and only a space exists between the SSI command and the parameter. The above punctuation = "" cannot be less than one. The SSI command is case sensitive, so the parameter must be in lower case. SSI instructions # echo Demonstration: inserts environment variables into the page. Syntax: <! -- # Echo Var = "variable name" --> example: <! -- # Echo Var = "document_name" --> name of this document <! -- # Echo Var = "date_local" --> current time <! -- # Echo Var = "remote_addr" --> your IP address # include: insert the content of a text file to the document page. Syntax: <! -- # Include file = "file name" --> <! -- # Include virtual = "file name" --> the file name is a relative path, which is relative to the directory of the document using the # include command. The contained file can be in the same level directory or its sub-directory, but not in the upper level directory. For example, the nav_head.htm document under the current directory is file = "nav_head.htm ". The Virtual File name is the complete path of the virtual directory on the web site. For example, if the parameter is relative to the nav_head.htm file in the hoyidirectory under the Server File root directory, it is the file = "/hoyi/nav_head.htm" parameter: file specifies the location of the file to be included in this document. If the parameter is false: the file name must have an extension. The contained file can have any file extension. I think it is most convenient to directly use the HTM extension. Microsoft recommends using the. inc extension (which depends on your hobby ). Example: <! -- # Include file = "nav_head.htm" --> Insert the header file to the current page. <! -- # Include file = "nav_foot.htm" --> Insert the last file to the current page # flastmod and # fsize demonstrate function: # The Last Update date of the flastmod file # fsize file length Syntax: <! -- # Flastmod file = "file name" --> <! -- # Fsize file = "file name" --> parameter: file specifies the location of the contained file relative to this document, such as info.txt. When the info.txt file in the current directory is virtual, it specifies the location relative to the root directory of the Server File, such as/hoyi/info.txt. Note: The file name must have an extension. Example: <! -- # Flastmod file = "news.htm" --> Insert the latest update date of the news.htm file in the current directory to the current page. <! -- # Fsize file = "news.htm" --> Add the news.htm file in the current directory to the current page. # Exec: insert the output of an external program to the page. The input of a CGI program or a general application can be inserted, depending on whether the parameter is cmd or CGI. Syntax: <! -- # Exec cmd = "file name" --> <! -- # Exec CGI = "file name" --> parameter: cmd general application CGI script example: <! -- # Exec cmd = "cat/etc/passwd" --> the password file is displayed. <! -- # Exec cmd = "DIR/B" --> the file list in the current directory is displayed. <! -- # Exec CGI = "/cgi-bin/GB. cgi" --> the CGI program GB. cgi is executed. <! -- # Exec CGI = "/cgi-bin/access_log.cgi" --> the CGI program access_log.cgi is executed. Note: As shown in the preceding example, this command is quite convenient, but there are also security problems. Method prohibited: Apache. in Conf, the "options between des execcgi" line of code is deleted. In IIS, to disable the # EXEC command, you can modify the ssiexecdisable metadatabase; # The role of config: specifies the error message, date, and file size returned to the client browser. Syntax: <! -- # Config errmsg = "custom error message" --> <! -- # Config sizefmt = "display unit" --> <! -- # Config timefmt = "display format" --> parameter: errmsg custom SSI execution error message, which can be any method you like. The display mode of sizefmt file size. The default mode is byte mode ("bytes"). You can change the display mode of timefmt time in the kilobytes ("abbrev") mode to the most flexible configuration attribute. Example: display the size of a non-existing file <! -- # Config errmsg = "server execution error, please contact the Administrator yiho@126.com, thank you! "--> <! -- # Fsize file = "nonexistent file .htm" --> display file size in kilobytes Syntax: <! -- # Config sizefmt = "abbrev" --> <! -- # Fsizefile = "news.htm" --> display time in a specific time format <! -- # Config timefmt = "% Y year/% m month % d day week % W Beijing time % H: % m: % s, % Y years passed % J days today is % u week of % Y years "--> <! -- # Echo Var = "date_local" --> display the day of the week, month, and Time Zone <! -- # Config timefmt = "today % A, % B, server time zone is % Z, yes" --> <! -- # Echo Var = "date_local" --> xssixssi (Extended SSI) is a set of advanced SSI commands built into the mod-include module of Apache 1.2 or later. The following commands can be used: # printenv # Set # If # printenv: displays all environment variables currently in the web server environment. Syntax: <! -- # Printenv --> # Set: You can assign values to variables for the IF statement. Syntax: <! -- # Set Var = "variable name" value = "variable value" --> example: <! -- # Set Var = "color" value = "red" --> # If: Create a page that can change the data. The data is displayed according to the requirements calculated when the if statement is used. Syntax: <! -- # If expr = "$ variable name = \" variable value A \ "" --> display content <! -- # Elif expr = "$ variable name = \" variable value B \ "" --> display content <! -- # Else --> display content <! -- # Endif "--> example: <! -- # If expr = "$ SERVER_NAME = \" www.baidu.com \ "--> welcome to http://www.baidu.com <! -- # Elif expr = "$ SERVER_NAME = \" www.google.com \ "--> welcome to http://www.google.com <! -- # Else --> welcome to afly's blog! <! -- # Endif "--> Note: it is used for the backslash in the preceding command to replace the internal quotation marks so that they are not interpreted as an end expression. It cannot be omitted. 1. The Config command is mainly used to modify the default settings of SSI. Errmsg: sets the default error message. To return user-defined error messages normally, the errmsg parameter in the HTML file must be placed before other SSI commands; otherwise, the client can only display default error messages, instead of user-defined information. <! -- # Config errmsg = "error! Please email webmaster@mydomain.com "--> timefmt: defines the format of use of date and time. The timefmt parameter must be used before the echo command. <! -- # Config timefmt = "% A, % B % d, % Y" --> <! -- # Echo Var = "last_modified" --> the result is Wednesday, and limit l 12,200 0. Maybe the user is unfamiliar with % A % B % d in the previous example, below we will summarize some commonly used Date and Time formats in SSI in the form of tables. Sizefmt: determines whether the file size is expressed in bytes, kilobytes, or megabytes. In bytes, the parameter value is "bytes". You can use the abbreviations for kilobytes and megabytes. Similarly, the sizefmt parameter must be placed before the fsize command. <! -- # Config sizefmt = "bytes" --> <! -- # Fsize file = "index.html" --> 2. The include command can insert text or images from other documents into the parsed documents. This is the key of 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: Virtual: the virtual path to a document on the server. File: Specifies the relative path to the current directory. "../" cannot be used or an absolute path. <! -- # Include virtual = "/Includes/header.html" --> <! -- # Include file = "header.html" --> in this case, each directory contains a header.html file. 3. The echo command displays the following environment variables: document_name: displays the name of the current document. Document_uri: displays the virtual path of the current document. Example: <! -- # Echo Var = "document_name" --> <! -- # Echo Var = "document_uri" --> As the website continues to grow, those longer and longer URL addresses 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 <! -- # Echo Var = "document_uri" --> query_string_unescaped: displays unescaped query strings sent by the client. All special characters are preceded by the Escape Character "\". Example: <! -- # Echo Var = "query_string_unescaped" --> date_local: displays 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. Example: <! -- # Config timefmt = "% A, the % d of % B, in the year % Y" --> <! -- # Echo Var = "date_local" --> the result is Saturday, the 15 of each l, in the year 2000date_gmt. The function is the same as that of date_local, however, the returned date is based on the Greenwich Mean Time. Example: <! -- # Echo Var = "date_gmt" --> last_modified: displays the Last Update Time of the current document. Similarly, this is a very practical feature of SSI. You only need to add the following simple lines of text to the HTML document to dynamically display the Update Time on the page. <! -- # Echo Var = "last_modified" --> besides the SSI environment variables, the echo command also displays the following CGI Environment Variables: server_software: the name and version of the server software. Example: <! -- # Echo Var = "server_software" --> SERVER_NAME: displays the host name, DNS alias, or IP address of the server. Example: <! -- # Echo Var = "SERVER_NAME" --> server_protocol: displays the protocol name and version used by the client request, such as HTTP/1.0. Example: <! -- # Echo Var = "server_protocol" --> server_port: display the server's response port. Example: <! -- # Echo Var = "server_port" --> request_method: displays the client's document request methods, including get, Head, and post. Example: <! -- # Echo Var = "request_method" --> remote_host: displays the name of the client host that sends the request information. <! -- # Echo Var = "remote_host" --> remote_addr: displays the IP address of the client that sends the request information. <! -- # Echo Var = "remote_addr" --> auth_type: shows the authentication method for user 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: displays the size of the specified file. You can use the sizefmt parameter of the config command to customize the output format. <! -- # Fsize file = "index_working.html" --> 5. flastmod: displays the last modification date of the specified file. You can use the timefmt parameter of the config command 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 update dates of all links 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" --> the result is: file limit l 19,200 0 another file January 08,200 06. execexec commands can execute CGI scripts or shell commands. The usage is as follows: cmd: run the specified string using/bin/sh. 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: <! -- # Exec CGI = "/cgi-bin/counter. PL "--> for the differences between shtml and HTML, let's take a look at the differences between shtml and HTML. If we use one sentence to explain that shtml is not HTML but a Server API, shtml is the HTML dynamically generated by the server. both are in hypertext format, but shtml is a file used for SSI technology. That is, the server side include -- SSI server contains commands. If the Web server has the SSI function, most (especially UNIX-based) Web servers, such as Netscape Enterprise Server, support SSI commands.
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.