"Server-side learning" modifies the Apache configuration to enable support for shtml

Source: Internet
Author: User
Tags echo command


Main work: Modify httpd.conf file
Step one remove the comments from the following two lines
#AddType text/html. shtml
#AddOutputFilter includes. shtml
"Step Two" after the options Indexes followsymlinks plus includes

=================================================================================================

The following is from Http://www.alixixi.com/web/a/2008101544260.shtml, and is left as a note.

SSI Instruction Basic Format

<!--directive name = "directive Parameters" >

Example:<!--#include file= "info.htm"-

Description

    1. <!----> is a comment in HTML syntax that is ignored when the Web server does not support SSI.
    2. #include is one of the SSI directives.
    3. File is an include parameter, info.htm is the parameter value, and the name of the document that will be included in this directive.

Attention:

    1. There is no space between the <!--and the # number, only a space exists between the SSI directive and the parameter.
    2. Above the punctuation = "", one can not be less.
    3. SSI directives are case-sensitive, so the parameters must be lowercase to work.

Use of SSI instructions

#echo Demonstration

Action: Inserts an environment variable into the page.

Syntax:<!--#echo var= "variable name"--

Example:

<!--#echo var= "Document_name"--the name of this document
<!--#echo var= "date_local"-present time
<!--#echo var= "REMOTE_ADDR"--Your IP address

#include demonstration

Function: Inserts the contents of the text file directly into the document page.

Grammar:

<!--#include file= "file name"--
<!--#include virtual= "file name"--

The file file name is a relative path to the directory that contains the document that uses the #include directive. The included files can be in the same level directory or in their subdirectories, but not in the top level directory. File= "Nav_head.htm" If the nav_head.htm document is represented in the current directory.
The virtual file name is the full path to the virtualized directory on the Web site. File= "/hoyi/nav_head.htm" if the nav_head.htm file is relative to the Hoyi directory under the root directory of the server document;

Note: The file name must have an extension. The included files can have any file extension and I think it is most convenient to use the HTM extension directly, and Microsoft recommends using the. inc extension (which depends on your hobby).

Example:

<!--#include file= "nav_head.htm"--Inserting header files into the current page
<!--#include file= "nav_foot.htm"--Inserts a tail file into the current page

#flastmod and #fsize Demonstrations

Role:

Date #flastmod file was last updated

Length of #fsize file

Grammar:

<!--#flastmod file= "file name"--

<!--#fsize file= "file name"--

Parameters:

file specifies the location of the containing file relative to this document, such as Info.txt represents the Info.txt document in the current directory

virtual Specifies the location relative to the server document root directory, as/hoyi/info.txt represents

Note: The file name must have an extension.

Example:

<!--#flastmod file= "news.htm" and inserts the last updated date of the news.htm file in the current directory into the current page
<!--#fsize file= "news.htm" to the current page with news.htm file size in the current directory

#exec Demonstration

Function: Inserts the output of an external program into the page. You can insert a CGI program or an input to a regular application, depending on whether the parameter used is CMD or CGI.

Grammar:

<!--#exec cmd= "file name"--

<!--#exec cgi= "file name"--

Parameters:

cmd general application

CGI CGI Script Program

Example:

<!--#exec cmd= "cat/etc/passwd"-the password file will be displayed
<!--#exec cmd= "dir/b"-Displays a list of files in the current directory
<!--#exec cgi= "/cgi-bin/gb.cgi"-The CGI program gb.cgi will be executed.
<!--#exec cgi= "/cgi-bin/access_log.cgi"-The CGI program access_log.cgi will be executed.

Note: This instruction is quite handy from the example above, but there are also security issues.

Forbidden Method:

Apache, will be access.conf in the "Options includes execcgi" This line of code deleted;

In IIS, to disable the #exec command, you can modify the SSIExecDisable metabase;

#config

Function: Specifies the format of the error message, date, and file size returned to the client browser.

Grammar:

<!--#config errmsg= "Custom error Messages"-

<!--#config sizefmt= "Display units"-
<!--#config timefmt= "display format"-

Parameters:

errmsg Custom SSI Executes the error message, which can be any way you like.

sizefmt File size display, default to byte mode ("bytes") can be changed to kilobytes ("abbrev")
timefmt Time display mode, the most flexible configuration properties.

Example:

Displays a file size that does not exist

<!--#config errmsg= "Server execution error, please contact the Administrator [email protected], thank you! "-

<!--#fsize file= "files that do not exist. htm"-

Display file size in kilobytes

Grammar:

<!--#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 year has passed%j days today is%y year the first%u weeks"-

<!--#echo var= "date_local"-Displays today's Day of the week, months, time zone
<!--#config timefmt= "Today%a,%B, server time zone is%z, yes"-
<!--#echo var= "Date_local"-

Xssi

Xssi (Extended SSI) is a set of advanced SSI instructions built into the Mod-include module in Apache 1.2 or later. Among the available directives are:

#printenv

#set

#if

#printenv

Function: Displays all environment variables that currently exist in the Web server environment.

Grammar:

<!--#printenv-

#set

Function: You can assign a value to a variable for use in subsequent if statements.

Grammar:

<!--#set var= "variable name" value= "Variable Value"-

#if

Action: Create a page that can change the data, which is displayed according to the requirements that are computed when using the IF statement.

<!--#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: The backslash used in the preceding instruction is used to replace the inner quotation marks so that they are not interpreted as an end-expression. cannot be omitted.

1. Config command

The Config command is primarily used to modify SSI's default settings. which

errmsg: Sets the default error message. In order to return the user-set error message normally, the errmsg parameter must be placed in front of other SSI commands in the HTML file, otherwise the client can only display the default error message, not the custom information set by the user.

<!--#config errmsg= "error! please email [email protected] "--

timefmt: Defines the use format for dates and times. The TIMEFMT parameter must be used before the echo command.

<!--#config timefmt= "%A,%B%d,%Y"-
<!--#echo var= "last_modified"-

Display results: Wednesday, April 12, 2000

Perhaps the user is unfamiliar with the%a%B%d used in the above example, let's summarize some of the more commonly used date and time formats in SSI in tabular form.

sizefmt: Determines whether the file size is expressed in bytes, kilobytes, or megabytes. If the parameter value is "bytes" in bytes, abbreviations can be used for kilobytes and megabytes. Similarly, the SIZEFMT parameter must be placed before the fsize command to be used.

<!--#config sizefmt= "bytes"-
<!--#fsize file= "index.html"-

2. Include command

The Include command can insert text or images from other documents into the currently parsed document, which is the key to the entire SSI. With the include command, you can update an entire site in just one file.

Parameters:

Virtual: gives the path to a document on the server side.
File: gives the relative path to the current directory, where you cannot use the ".. /", nor can you use absolute paths.

<!--#include virtual= "/includes/header.html"-
<!--#include file= "header.html"--this requires that each directory contain a header.html file.

3. Echo command

The Echo command can display the following environment variables:

document_name: Displays the name of the current document.

Document_uri: Displays the virtual path of the current document. For example:

<!--#echo var= "Document_name"-
<!--#echo var= "Document_uri"-

With the development of the website, those increasingly long URLs will certainly make people headache. If you use SSI, everything will be resolved. Because we can combine the domain name of the website with the SSI command to display the complete URL, namely:

http://yourdomain<!--#echo var= "Document_uri"-

query_string_unescaped: Displays the non-escaped query string sent by the client, where all the special characters are preceded by the escape character "\". For example:

<!--#echo var= "query_string_unescaped"-

date_local: Displays the date and time when the server sets the time zone. The user can customize the output information with the TIMEFMT parameter of the config command. For example:

<!--#config timefmt= "%A, the%d of%B, in the year%Y"-

<!--#echo var= "Date_local"-

The results shown are:

Saturday, the. April, the year 2000

date_gmt: The function is the same as date_local, except that it returns a date that is based on Greenwich Mean time. For example:

<!--#echo var= "DATE_GMT"-

last_modified: Displays the last update time of the current document. Again, this is a very useful feature in SSI, as long as you add the following simple text to the HTML document, you can dynamically display the update time on the page.

<!--#echo var= "last_modified"-

CGI Environment variables

In addition to the SSI environment variables, the echo command can also display the following CGI environment variables:

Server_software: Displays the name and version of the Server software. For example:
<!--#echo var= "Server_software"-
SERVER_NAME: Displays the host name, DNS alias, or IP address of the server. For example:
<!--#echo var= "SERVER_NAME"-
Server_protocol: Displays the protocol name and version used by the client request, such as http/1.0. For example:
<!--#echo var= "Server_protocol"-
Server_port: Displays the server's response port. For example:
<!--#echo var= "Server_port"-
Request_method: Displays the client's document request method, including get, HEAD, and post. For example:
<!--#echo var= "Request_method"-
Remote_host: Displays the name of the client host that sent the request information.
<!--#echo var= "Remote_host"-
REMOTE_ADDR: Displays the client IP address where the request information is made.
<!--#echo var= "REMOTE_ADDR"-
Auth_type: Displays the authentication method for the user's identity.
<!--#echo var= "Auth_type"-
Remote_user: Displays the name of the account used by the user who accessed the protected page.
<!--#echo var= "Remote_user"-

4, Fsize: Displays the size of the specified file, can be combined with the sizefmt parameter of the config command to customize the output format.

<!--#fsize file= "index_working.html"-

5, Flastmod: Display the last modified date of the specified file, you can combine 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 updated date of all linked pages on a page. Here's how:

<!--#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 results shown are:

File April 19, 2000

Another File January 08, 2000

6. Exec

The EXEC command can execute CGI scripts or shell commands. Here's how to use it:

CMD: Executes the specified string using/bin/sh. If SSI uses the INCLUDESNOEXEC option, the command will be masked.
CGI: Can be used to execute CGI scripts. For example, the following example uses the counter.pl script program in the server Cgi-bin directory to place a counter on each page:

<!--#exec cgi= "/cgi-bin/counter.pl"-

"Server-side learning" modifies the Apache configuration to enable support for shtml

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.