About the complete discipline of the SHTML file

xiaoxiao2021-03-06  42

SSI uses detailed explanation that you have troubles you have to complete the changes to a website containing thousands of pages in the shortest time? So you can look at this article, perhaps you can help you.

What is SSI?

SSI is the abbreviation of English Server Side Includes, translated into Chinese is the meaning of the server side. From a technical point of view, SSI is an HTML file, which can be called or pointers through the comment line. SSI has a powerful feature, as long as a simple SSI command can realize the content update, dynamic display time and date of the entire website, and perform complex features such as Shell and CGI scripts. SSI can be said to be the best helper for website developers who have a shortage of funds, time, and workload.

SSI is initially launched on the NCSA server platform, which is expanded and enhanced in the Apache server, which is now running on almost all servers. This article will mainly bind to the APACHE server to introduce the use of SSI.

How to start SSI?

Under the Apache server, you can create a .htaccess file to start SSI by direct editing the server profile or in a directory you need to use the SSI. Specifically, the process is as follows:

1. Server profile

If the user has access to the server profile, you can start SSI by editing file access.conf and srm.conf.

First use the Telnet remote login server to find the storage directory of the configuration file. In general, the configuration file of the Apache server is saved in the / usr / local / etc / httpd / confal directory. Use any text editor to open the file SRM.CONF, find the following lines:

# Imp You Want To Use Server Side Includes, or CGI Outside # ScriptaliaSed Directories, UNComment The Following Lines. # Addtype text / x-server-pased-html.shtml

#Addtype application / x-httpd-cgi .cgi

There may be no such annotation instruction lines in the user's configuration file, but as long as you find two rows starting with ADDTYPE and remove the "#" symbol of each row.

Save the modifications made, then open the file access.conf. Users need to find some of the part of setting the DocumentRoot (root file) in the file. Generally speaking, the text is as follows, but does not exclude $ # @ 60; Directory $ # @ 62; and $ # @ 60; / Directory $ # @ 62; the label also contains other settings content.

# @ 60; Directory / USR / local / etc / httpd / htdocs $ # @ 62; # this may also be "none", "all", or any combination of "Indexes", Options INDEXES FOLLOWSYMLINKS INCLUDES $ # @ 60; / Directory $ # @ 62;

If the user does not want to execute the script or shell command, you can add keyword INCLUDESNOEXEC in the Options option row, which allows SSI, but cannot perform CGI or script commands. (Note: The latest version of the Apache server has only one configuration file httpd.conf, and the content mentioned above has been included in this file)

2. Create a file .htaccess

If the user can't access the server profile directly, you can create a file called .htaccess file using the file editor. Note that the file name must have a symbol "." So the server can know that the file is hidden file, thereby increasing the security of the file, avoiding error operations. In the .htaccess file, you need to add the following three lines: options indexes backsymlinks includedtype application / x-httpd-cgi .cgiaddtype text / x-server-pased-html.shtml

After completion, you can upload the .htaccess file to the corresponding directory of the server, which is valid for all subdirectories. If the user wants to disable the CGI or shell command on the directory level, you can add keyword incrudesnoexec on the .htaccess file.

3. Use .shtml or .html?

Any file containing SSI must pass the server's parsing process before it is submitted to the client. Although a server's load is increased to some extent, the performance of a server does not have a significant decline unless a user's website has millions of access users every day. However, if it is not necessary to use SSI in each page, it is indeed necessary to let the server parses each page. If the user only wants to use SSI to use SSI in several special pages, you can change the file's suffix name to .shtml, so that the server can only resolve the .shtml file containing the SSI. On the other hand, if there is a multiple page using SSI, but the user does not want to use .SHTML's suffix name, you can use the following command line in the .htaccess file:

AddType text / x-server-pased-html .html

SSI syntax

SSI follows the following format when using:

$ # @ 60; - # Directive parameter = "value" - $ # @ 62;

Among them, Directive is the command name sent to the server. Parameter is the operation object of the instruction, and the value is the command processing result of the user desired. All ssi commands are started with "$ # @ 60;! - #", "$ # @ 60;! -" and "#" can't have any spaces, otherwise the server will call the ssi command as ordinary The file comment processing does not show any result, nor does it generate an error message. In addition, "=" in the SSI command does not have spaces, and the value on the right must be included in the double quotes, and the back can be followed by the space, and finally the label "- $ # @ 62;".

The SSI command contains six major classes and their respective parameters, as follows:

Directives Parameters config errmsg, timefmt, sizefmt incrude Virtual, File Echo var fsize file flastmod file Exec CMD, CGI

Below we will introduce one by one.

1.config command

The config command is primarily used to modify the default settings of the SSI. among them:

Errmsg: Set the default error message. In order to be able to return the user setting error information, the errmsg parameter must be placed in front of the other SSI command in the HTML file, otherwise the client can only display the default error message instead of the custom information set by the user.

$ # @ 60;! - # config errmsg = "Error! Please email webmaster@mydomain.com - $ # @ 62;

Timefmt: Defines the use format of the date and time. The TimeFmt parameter must be used before the echo command.

$ # @ 60; - # config timefmt = "% a,% b% d,% y" - $ # @ 62; $ # @ 60;! - # echo var = "las_modified" - $ # @ 62;

The display result is:

Wednesday, April 12, 2000

Perhaps the user is very unfamiliar with the% a% B% D used in the previous example. Here we summarize some of the more common date and time formats in the SSI in the form of a table.

Format Description Instance %% %% A week seven days of abbreviation Form THU% a week seven days thursday% B months Abbreviation Form APR% B Apr Min 1 month 13% D MM / DD / YY Date Format 04 / 13/00% h hours (24-hour system, from 00 to 23) 01% i hour (12 hours, from 00 to 11) 01% J, from 01 to 365 104% M within one year The first few minutes from 01 to 12 04% M, from 00 to 59 10% P AM or PM% R 12 hours, format% i:% m:% S am | PM 01:10:18 AM% S in the first minute of one minute, from 00 to 59 18% T 24 hour% h:% m:% s time format 01:10:18% u one year The first day of 00 to 52, from 00 to 52, as the first day of each week, the first day of each week, from 0 to 6 4% W One year in the year, from 00 to 53. As a result of 15% Y year, the first day of each week, from 00 to 99 00% Y, from 00 to 99 00% Y, a four-digit number represents a year 2000% z time zone name MDT

SIZEFMT: Deciding that the file size is indicated by bytes, kilobytes or megabytes. If in bytes, the parameter value is "BYTES"; the abbreviated form can be used for kilobytes and megabytes. Similarly, the SIZEFMT parameter must be placed in front of the fsize command.

$ # @ 60; - # config sizefmt = "bytes" - $ # @ 62;

$ # @ 60; - # fsize file = "index.html" - $ # @ 62;

转载请注明原文地址:https://www.9cbs.com/read-60264.html

New Post(0)