Review
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 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
注意, 高版本的Apache可能是这几行:
#
# 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 be changed to whatever you set DocumentRoot to.
<Directory /usr/local/etc/httpd/htdocs>
# This may also be "None", "All", or any combination of "Indexes",
# "Includes", or "FollowSymLinks"
Options Indexes FollowSymLinks
</Directory>
将其中的Options Indexes FollowSymLinks改为:
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 the following three lines of text before the filename ".". 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