SSI usage (1)

Source: Internet
Author: User
Tags echo command

Have you ever been or are you worried about how to modify a website containing thousands of pages in the shortest time? So you can take a look at the introduction of this article, which may be helpful to you.

What isSSI?

SSI is the abbreviation of Server Side encryption DES. Technically speaking, SSI is a command or pointer that can be called through the annotation line in an HTML file. SSI has powerful functions. You only need to use a simple SSI command to update the content of the entire website, dynamically display the time and date, and execute complicated functions such as shell and CGI scripts. SSI can be called the best helper for website developers who have a shortage of funds, time shortage, and heavy workload.

SSI was initially launched on the NCSA server platform and has been expanded and enhanced on Apache servers. It can now run on almost all servers. This document describes how to use SSI Based on the Apache server.

How to startSSI?

On the Apache server, you can directly edit the server configuration file or create a. htaccess file in the directory where SSI is needed to start SSI. Specifically, the process is as follows:

1. Server Configuration File

If you have access to the server configuration file, you can edit the file access. conf and srm. conf to start SSI.

First, use Telnet to remotely log on to the server and find the directory where the configuration file is stored. Generally, the configuration files of the Apache server are stored in the "/usr/local/etc/httpd/conf" directory. Open the srm. conf file in any text editor and find the following lines:

# If you want to use server side except des, or CGI outside
# ScriptAliased directories, uncomment the following lines.
# AddType text/x-server-parsed-html. shtml

# AddType application/x-httpd-CGI. CGI

The preceding annotation command line may not exist in the configuration file, but you only need to find the two lines starting with AddType and remove the '#' symbol at the beginning of each line.

Save the modification, and then open the file access. conf. You need to find the part that sets DocumentRoot in the file. In general, the text of this section is as follows, but it does not exclude $ # @ 60; Directory $ # @ 62; and $ # @ 60;/Directory $ # @ 62; tags also contain other settings.

# This shoshould be changed to whatever you set DocumentRoot.
$ # @ 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 you do not want to execute scripts or shell commands, you can add the keyword IncludesNOEXEC to the options Option line to allow SSI, but not CGI or script commands. (Note: the Apache server of the latest version has only one configuration file httpd. conf. All the above mentioned content has been included in this file)

2. Create a file. Htaccess

If you cannot directly access the server configuration file, you can use the file editor to create a file named. htaccess. Note that the file name must be preceded by the symbol "." so that the server can know that the file is a hidden file, which improves the file security and avoids incorrect operations. Add the following three lines of text to the. htaccess file:

Options Indexes FollowSymLinks Includes
AddType application/x-httpd-CGI. CGI
AddType text/x-server-parsed-html. shtml

After that, you can upload the. htaccess file to the corresponding directory on the server. This file is valid for all subdirectories. If you want to disable CGI or shell commands at the directory level, you can add the keyword IncludesNOEXEC to the Options Option line in the. htaccess file.

3.use .shtmlor .html?

Any file containing SSI must go through the parsing process of the server before it is uploaded to the client. Although the server load is increased to some extent, the performance of a server will not decrease unless the user's website has millions of users accessing it every day. However, if you do not need to use SSI on every page, there is indeed no need for the server to parse every page. Hosts file. On the other hand, if ssiis is used for multiple pages, but the suffix of .shtml is not expected by the user, you can use the following command line in the. htaccess file:

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

SSI syntax

SSI follows the following format during use:

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

Specifically, directive is the command name sent to the server, parameter is the operation object of the command, and value is the command processing result that the user wants.
All SSI commands use "$ # @ 60 ;! -- # ", Where" $ # @ 60 ;! -"And" # "cannot have any space between them. Otherwise, the server treats the SSI command as a normal file comment and does not display any results or generate error messages. In addition, there cannot be spaces on both sides of the "=" in the SSI command. The value on the right must be included in double quotation marks, followed by spaces, and the end tag "-- $ # @ 62 ;".

The SSI command contains six types of commands and their respective parameters, as shown in the following code:

Directives

Parameters

Config

Errmsg, timefmt, sizefmt

Include

Virtual, file

Echo

Var

Fsize

File

Flastmod

File

Exec

Cmd, cgi

There are two pages in this news. Currently, there are two pages in page 1st.


Next we will introduce them one by one.

1. Config command

The Config command is mainly used to modify the default settings of SSI. Where:

Errmsg:Set 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.

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

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

$ # @ 60 ;! -- # Config timefmt = "% A, % B % d, % Y" -- $ # @ 62;

$ # @ 60 ;! -- # Echo var = "LAST_MODIFIED" -- $ # @ 62;

The result is as follows:

Wednesday, 10000l 12,200 0

Maybe the user is unfamiliar with % A % B % d in the previous example. Below we will summarize some of the commonly used Date and Time formats in SSI in the form of A table.

Format

Description

Instance

%

%

 

%

Seven days a week

Thu

<

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.