SSI is the abbreviation of English server Side includes, translated into Chinese is the meaning that server side contains. From a technical standpoint, SSI is a command or pointer that is in an HTML file that can be invoked through a comment line. SSI is powerful, with a simple SSI command that enables content updates throughout the site, dynamic display of time and dates, and the execution of complex functions such as shell and CGI scripts. SSI can be called the best helper for Web developers who are short of cash, tense, and have a lot of work. This article will mainly combine the Apache server to introduce the use of SSI.
How do I start SSI?
Under the Apache server, you can start SSI by directly editing the server configuration file or by creating a. htaccess file in a directory that needs to use SSI. The specific process is as follows:
1. Server configuration file
If the user has access to the server configuration file, you can start the SSI by editing the files access.conf and srm.conf.
First log on to the server, locate the directory where the configuration file is located, open the file srm.conf using any type of text editor, and locate the following lines:
# If you are want to use server side includes, or CGI outside
# scriptaliased Directories, uncomment the following lines.
#AddType text/x-server-parsed-html. shtml
#AddType application/x-httpd-cgi. Cgi
Note that the high version of Apache may be these lines:
#
# to use server-parsed HTML files
#
#AddType text/html. shtml
#AddHandler server-parsed. shtml
The user's profile may not have the above comment instruction line, but just find two lines starting with AddType and remove the "#" symbol at the front of each line.
Save the changes, and then open the file access.conf. The user needs to find the part of the file that sets the DocumentRoot (root file). Generally, the text of the paragraph reads as follows:
# This should is changed to whatever your set DocumentRoot to.
<Directory/usr/local/etc/httpd/htdocs>
# This may also is ' None ', ' all ', or any combination of ' Indexes ',
# "Includes", or "followsymlinks"
Options Indexes FollowSymLinks
</Directory>
Change the options Indexes followsymlinks to:
Options Indexes followsymlinks Includes
If the user does not want to execute a script or shell command, you can include the keyword includesnoexec in the options option line, which allows SSI, but cannot execute CGI or script commands (note: In a higher version of the Apache server, All of the above mentioned items have been included in the configuration file httpd.conf.
2. Create a file. htaccess
If the user does not have direct access to the server configuration file, you can use the file editor to create a file named. htaccess. Note that you must have a symbol "." Before the file name, so that the server can know that the file is a hidden file, thereby improving the security of the file to avoid error operation. The following three lines of text need to be added to the. htaccess file:
Options Indexes followsymlinks Includes
AddType application/x-httpd-cgi. Cgi
AddType text/x-server-parsed-html. shtml
When you are done, you can upload the. htaccess file to the appropriate directory on the server, which is valid for all subdirectories. If the user wants to ban CGI or shell commands at the directory level, you can add keyword includesnoexec to the options option line in the. htaccess file.
3. Use of. shtml or. html?
Any file that contains SSI must undergo the server parsing process before uploading to the client. This increases the load on the server, and if the user only wants to use SSI on several special pages, the file's suffix name can be changed to. shtml so that the server can resolve only. shtml files that contain SSI. On the other hand, if you have multiple pages using SSI, but users do not want to use the. shtml suffix name, you can use the following command line in the. htaccess file:
AddType text/x-server-parsed-html. html
How do I use SSI?
SSI follows the following format when used:
!--#directive parameter= "value"-->
The directive is the instruction name sent to the server, parameter is the object of instruction, and value is the result of the command processing that the user wants.
All SSI commands start with "!--#", where there is no space between "<!-" and "#", or the server takes SSI commands as normal file annotations, does not show any results, and does not produce error prompts. In addition, there can be no spaces on either side of the "=" in the SSI command, and the value on the right must be enclosed in double quotes, followed by a space, and finally the end tag "-->".
The SSI command contains six classes of instructions and their respective parameters, as follows:
directive Name parameter list
Config errmsg, TIMEFMT, sizefmt
Include virtual, file
echo var
Fsize file
Flastmod file
exec cmd, CGI
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.