Fundamentals of Server Side Includes or SSI technology. SSI interface scripts apache SSI include include description tutorial SSI example support SSI directives


I want to tell you about the basics of technology server side includes or ssi.
ssi stands for "server-side includes". This technology helps save a lot of time when creating a site and uploading it to the server. In general, ssi is designed to make the work of the webmaster as easy as possible.

Here is a very real situation:
You have a site that doesn't use ssi, of course, with a number of pages close to: let's say at least 50 pages. So, on each page you, as a good webmaster who cares about his visitors, placed a text menu. And suddenly, for some reason, the name of a section has changed, or maybe you wanted to add a new one. What now to re-open all fifty pages and rewrite everything again and again?! In our case, this, unfortunately, is the only solution, however, some good editors will be able to lighten this unbearable burden (and how to make it easier!, homesite, for example).

So, such a problem would not have happened to you if you used ssi technology. I explain: if instead of a text menu on all pages, something like

And in the file "(www)/ssi/menu_txt.html" there would be the content of this menu, then in order to add or change the section, it would only be necessary to change the content of just one menu_txt.html file. As you probably already guessed in all pages instead of "comment"

the code from menu_txt.html will be inserted.

Syntax of ssi directives.

The syntax for ssi directives is:
All directives are enclosed in comments

The main difference ssi directives from the comment is the symbol "#" immediately(!) after "

and nothing else!

Here is a list of some ssi "functions" (they are written immediately after the "#" character)

include

Includes the text (code, content) of the specified document/file into the given document. The location of files on the server is specified using the following attributes:

file - you must specify the path relative to this document, that is, the included document/file must be located either in the same directory as this document, or in directories below/above (some_catalog/, ../some_catalog).
virtual - you can specify either a relative (as in the case of file) or an absolute path (may contain /some_catolog or ../some_catalog).

include allows you to include the result of cgi scripts, as well as access them with some given query string. For example,

Sets the value of some variable. A variable is declared with the var attribute, and its value is set with the value attribute.

the variable a will have the value variable.
And it's possible like this:

Variable a will be equal to varia$(c)
In order to substitute a variable, you need to enclose it in curly brackets and put $ in front of all this. If you want the dollar sign ($) to be displayed just as a symbol, and not denote a variable, then prefix it with a slash ()

echo

displays the value of the variable specified in the var attribute.

that is, instead of this code, the value of the variable a is inserted

Examples of using ssi.

Title:<!--#echo var="title" --> "> (!LANG:, html"> !}

Document Body

As you can see from this example, using ssi is not that difficult, and moreover, it is very useful.

Technical aspects of using ssi.

It is worth saying a few words about the technical support that is necessary to use ssi. If you just create a file on your local drive with the correct ssi commands and open it in your browser, then no inclusions will happen, because all expressions likefor the browser are pure comments. So-called "inclusions" occur at the stage of processing the document by the server, before sending it to the user. In our case, there is no such stage (document processing by the server) at all. So, in order for you to fully experience all the benefits of ssi on your local computer, you need a "home" web server.
And one more thing: not every hosting provider supports ssi. This is usually a problem with free hosting. But some of them, even if they allow the use of ssi, require a certain fee for this, for example, advertising on the site.

SSI (Server Side Includes) is a technology that allows you to conveniently “assemble” web pages from parts, insert the results of executing CGI scripts into them and give pages other elements of dynamics.

What files are processed as SSI, how to add your own files

By default, the web server only checks *.shtml files for SSI instructions. For example, put the SSI commands in the index.shtml file and it will immediately work. If there is a need to check other files for the presence of SSI, the appropriate extensions for checking can be added by placing the following instruction in the .htaccess file:

AddHandler server-parsed .ext1

.ext1 here is the extension of the files that should be checked for the presence of SSI in them. It is not recommended to add .html and .htm extensions, because in this case the server will check all html files for SSI inserts. This can lead to a completely pointless load on the server.

Restrictions

Hosting users have access to all SSI directives, with the exception of one restriction for subscribers who use a tariff that does not provide for running their own cgi scripts. For these clients, running scripts is also not available through SSI instructions. That is, in terms of Apache, the NoExec option works for them.

How SSI works and what it is used for

Beginning users can mainly use the SSI technology for two purposes: for "gluing" the page from parts of the html code and for running scripts in order to place the results of their work on the created html page. In the first case, the appropriate files are read from the server's disk and inserted into the code of the page from which the SSI code was called. In the second case, the web server, having found the SSI instruction, launches the script located on the disk and inserts the result of the script execution into the final page.

Let's take a closer look:

    "Gluing" the page from parts of the html code. It is used in order not to duplicate the same html code in multiple web pages. For example, you can take the entire design into SSI inclusions, which are included in a specific html file, which will contain only the text of a specific page.

    Let's put the "header" of the web page (design elements, menus, necessary links and other elements that are present on all pages) in the header.inc file, and put the bottom of the web page (the final part of the design) in the footer.inc file. Next, let's create a file called index.shtml that will look like this:

    And here we will have the main text of the page;

    It is assumed that we have placed html code at least like start / end tags in the include files , , and so on. As a result, the user will receive a page that will first include the contents of the header.inc file, then the words "And here we will have the main text of the page" and then the contents of the footer.inc file.

    This use of SSI is convenient from the point of view of the absence of the need to insert the same html code into newly created pages all the time, and also from the point of view of the convenience of changing the main elements of the site - we change the html code in one place, which immediately changes on all pages according to the entire site.

    Running scripts and placing the results of their work on the created html page. Thus, almost any functionality can be placed on the page, for example, in Perl (or another programming language supported by the hosting).

    For example, you have a counter script that shows how many visitors visited your page and it is located at /cgi-bin/count.pl. Let's include the result of his work in a web page. To do this, place the following SSI code in the html page code:

    As a result, on the page that the user sees, the counter that the script displayed will be placed /cgi-bin/count.pl.

    A complete list of SSI commands can be found in the description of the mod_include Apache module.

More examples of using SSI

SSI instructions can be used for more than just running scripts and including files. SSI also allows you to work with web server environment variables, manipulate dates, execute commands by condition, and so on. A good description of the most common uses of SSI commands can be found on the CIT Forum server.

Diagnosing errors when using SSI

If, when using SSI commands on your html pages, you see the message "", this indicates an error occurred while processing the SSI instruction by the web server.

Possible reasons for this error.

#include virtual like #include file includes the text of another file in the current file or runs cgi-script. Unlike #include file, it can contain a relative or absolute path without a protocol name (HTTP://) and a domain name (site) that is, it cannot point to a file from another site (PHP is used to export files from another site).

The directive allows paths like:

example/_ssi.html points to the _ssi.html file located in the example subdirectory of the current directory.

../_ssi.html points to the _ssi.html file located in the directory in which the current one (parent) is nested.

/_ssi.html points to the _ssi.html file located in the root directory of the site (for this file http://site/_ssi.html).

For example:

#fsize file Inserts the size of the specified file. The file whose size is determined must be located on the same site as the file containing this instruction. Moreover, it must be either in the same directory or in a subdirectory.

For example:

#fsize virtual Inserts the size of the specified file. Unlike #fsize, a file can contain a relative or absolute path without the protocol name (HTTP://) and domain name, and thus point to a file in another directory on the same site.

For example: Outputs the size of the given file: 37K.

The size format is determined by the SSI instruction.

#flasmod file Inserts the last modification date of the specified file. The file whose modification date is being determined must be located on the same site as the file containing the instruction. Also, it must be located either in the same directory or in a subdirectory.

For example:

#flasmodvirtual Inserts the last modification date of the specified file. Unlike #flastmod, a file can contain a relative or absolute path without the protocol name (HTTP://) and domain name, and thus point to a file in another directory on the same site.

For example: Displays the last modification date of the given file: 08/10/2014.

The date format is determined by the SSI instruction.

#exec cmd Runs an external program and inserts the result of its execution into the page content.

For example,

#exec cgi Like #exec cmd runs a cgi script and inserts the result of its execution into the page content.

For example,

#config errmsg defines the message that is displayed in the text when an error occurs. Since the message is printed directly into the body of the page, it might make sense to cast it to an empty line ( ) or ask the visitor to report an error to the author ().

#config timefmt defines the date format for the command using the following parameters:

SSI directive format #config timefmt
FormatDescriptionExample
FormatDescriptionExample
%aShort name of the day of the weekMon
%AFull name of the day of the weekMonday
%bMonth name abbreviationDec
%BFull month nameDecember
%dDay of the month01 (not 1)
%DDate in the format "%m/%d/%y"12/31/99
%eDay of the month13
%HHours in 24-hour format13
%IHours in 12 hour format01
%jday of the year235
%mMonth number01
%Mminutes03
%pAM/PM (AM/PM)AM
%rTime in the format "I:M:S p"11:35:46PM
%SSeconds34
%sTime in seconds since 01/01/1970957228726
%TTime in the format "%H:%M:%S"14:05:34
%UWeek of the year16
%wDay of the week number4
%yYear in YY format99
%YYear in YYYY format1999
%ZTime zoneMSK

As a result, an unprepared team gives the following output: 08/10/2014

And the same command, after the SSI directive , will issue: 08/10/2014

#config sizefmt defines the size format for the command. configures to display the file size in kilobytes (37K), and in bytes (37,782)

#printenv Like the good old DOS SET command, prints the current values ​​of environment variables, such as:

HTTP_USER_AGENT The name of the browser the visitor is using.

REMOTE_ADDR IP address of the visitor.

REMOTE_HOST Visitor's address in normal form.

SERVER_ADDR Site IP address.

SERVER_NAME server address.

CHARSET_HTTP_METHOD protocol ((none))

REQUEST_METHOD page request method (GET)

HTTP_HOST site name (site)

REQUEST_URI the entire query string, without specifying the protocol and site name (/docs/ssi.html)

QUERY_STRING everything that was in the address bar after the question mark (usually these are form parameters) Try to call this page with some parameters after the question mark and you will see them here ()

SCRIPT_NAME full path to the page from the site root (/docs/ssi.html)..html).

DOCUMENT_NAME only the file name. (ssi.html)

HTTP_REFERER the page from which they went to this page ((none))

SCRIPT_FILENAME Full path to the page on the server (/home/users/s/supervisork/domains/site/docs/ssi.html)

SERVER_SOFTWARE the name of the server and installed modules.

SERVER_ADMIN mail address of the server owner, specified during installation.

DATE_LOCAL Today's time and date in your time zone.

DATE_GMT the same, but GMT.

LAST_MODIFIED date and time when the page was last updated.

Practical application command has only for debugging the page, which is very important, given the fact that each server has its own set of variables. Here's what happens as a result of its application on the site:

Downgrade-1..76.94.14 HTTP_X_PROTOCOL=HTTP/1.1 HTTP_X_SERVER_IP=81.177.135.112 HTTP_X_FORWARDED_FOR=144.76.94.14 HTTP_X_FORWARDED_PROTOCOL=http HTTP_CONNECTION=close HTTP_USER_AGENT=Mozilla/5.0 (google; Googlebot/2.1; com/bot..177.135.112 SERVER_PORT=80 REMOTE_ADDR=144.76.94..ru SCRIPT_FILENAME=/home/users/s/supervisork/domains/website/docs/ssi.html REMOTE_PORT=32920 GATEWAY_INTERFACE=CGI/1.1 SERVER_PROTOCOL=HTTP /1.0 REQUEST_METHOD=GET QUERY_STRING= REQUEST_URI=/docs/ssi.html SCRIPT_NAME=/docs/ssi.html DATE_LOCAL=03/17/2019 DATE_GMT=03/17/2019 LAST_MODIFIED=08/10/2014 DOCUMENT_URI=/docs/ssi.html USER_NAME =supervisork DOCUMENT_NAME=ssi.html WORDS= KEYW= DESCRIP= TITL= HEAD= ROB=index, follow BROWSER=Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) DIR =PER=YES

However, the variables themselves are used frequently. For example, in the SSI directive #echo var.

#echo var Used to display the value of a variable specified as a parameter.

For example:

Your IP Your browser My server You came from page You are on the page http://

Outputs the following text:

Your IP 144.76.94.14 Your browser Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) My server webdesign.site3k..html

In newer versions of SSI, by default the SSI echo command uses the entity encoding and the encoding parameter has been added. Encoding must be specified BEFORE the var parameter. Possible encoding values:

entity- (by default) special HTML characters will be converted into entities and Russian text in Windows-1252 encoding will turn into krakozyabry (the purpose of this conversion is not clear);

url- an escape transformation will be performed, all characters of all the English alphabet will become %nn, where nn is the character code in hexadecimal encoding, which will allow them to be used in the URL string;

none- no conversions will be performed (as before, with the only difference that HTML entities that were previously encoded will not be encoded and angle brackets and ampersands can be inserted into SSI variables).

Example:

#set var value Sets the value of the variable, if the variable does not exist creates. Command format set var=" VARIABLE_NAME "value="(!LANG: ITS_VALUE !}"

For example, this code:

The value of the variable SERVER_NAME=" " » Change the value: Now the value of the variable SERVER_NAME=" »

Will output the following lines:

The value of the variable SERVER_NAME="site" Change the value: Now the value of the variable SERVER_NAME="discoverer.by.ru"

Of course, replacing standard environment variables may not make sense at all, but assigning your own variables can be convenient, for example:

To use the command at the right place on the page

It looks like this: This is the most visual guide to SSI(Note that special characters in the old version of SSI will be re-encoded to display on the page and not work as expected.

Naturally, you need to define a variable before it is applied on the page.

The ability to work with variables is one of the most important features of SSI. Without it, this technology would not be so widespread.

SSI operations and operators.

SSI does not support math or string operations. However, SSI technology supports substitutions, which can be regarded as analogous to concatenation. Substitution allows you to use environment variables as parameters of SSI directives and combine the values ​​of variables and strings (concatenate). When substituting, variables are enclosed in curly braces " {} ”, and are preceded by a dollar sign “ $ ” (sometimes the brackets can be omitted).

For example:

Put the full path and name of the given page into the NEW_VAR variable and output it to text:

http://website/docs/ssi.html

If it is necessary to include dollar signs, slashes, curly braces and quotation marks in the substitution, they are preceded by a slash:

\$ \/ \" \{ \}

#if, #elif, #else and #endif Conditional statements. They allow you to execute code or display text on the page, depending on the result of a logical comparison. Code that does not match the condition will not appear in any way even when viewing the "source code".

Operator format:

HTML code to be displayed if FIRST_CONDITION is true HTML code to be displayed if FIRST_CONDITION is false and SECOND_CONDITION is true HTML code to be displayed if all conditions are false

A condition is either a string that is true if it is non-empty, or a set of string comparison operators. Operators can be:

    Equality = Inequality != Less < Less than or equal <= More > Greater than or equal >= Negative (not true) !

If the second line is enclosed in a slash ("/"), it is a regular expression. For example, the condition is true if the first line contains at least one occurrence of the second line.

You can combine multiple comparison operators using the operators && ("logical AND") and || ("logical OR"). Parentheses are used to group conditions. To include variables in a condition, they are preceded by a dollar sign. For example:

Page requestedOpera browserbrowser Microsoft Internet ExplorerNetscape Navigator browsersearch robot

Result:

Page requested by Netscape Navigator browser

Attention: Any SSI directive must begin with the characters (end of comment). At the same time, there must be at least one space between the end of the SSI directive and the hyphens of the end of the comment otherwise the server may not correctly recognize the directive, mistaking hyphens and an angle bracket for the end of the command.

Features of SSI scripts

  • SSI Server Side Includes translates as server-side inclusion. The name itself displays the main features of SSI:
  • SSI instructions do not work on local computers, they are processed only by WEB servers, and how the page will look like in the end can only be seen by placing it on the server and loading it from there in the browser. Before issuing a page, the server reads it line by line, and, finding SSI instructions, processes it, inserting the result of execution instead of them. The instructions themselves are not saved in the page received by the visitor.
  • SSI cannot include files from another domain.
  • SSI is not supported by all servers, and server owners must indicate its support in the host description.
  • SSI is not processed in all files. In many files, the content is simply not parsed for the content of SSI instructions this is done so as not to slow down the server with unnecessary processing. The file types to be processed are specified in the description of the host. Also, they can be viewed in httpd.conf or srm.conf (if you have access to them). The following lines indicate the parsing of SSI instructions: AddType text/html .shtml AddHandler server-parsed .shtml Usually these are HTM, HTML and SHTML files.
  • Sometimes processing SSI directives requires placing an .htaccess file (the name starts with a dot) at the root of the site, with instructions like AddHandler server-parsed .shtml AddHandler server-parsed .html This may be the only way to affect the operation of the server if you are not its administrator.
  • Sometimes bad admins forbid the execution of PHP scripts in SSI directives, and instead of the result of the script execution, an inscription like
    ""
    In this case, you need to add the Options +Includes directive to .htaccess. For more information about the .htaccess file, see "Configuring the .htaccess file"
  • SSI is not processed in all directories. In order for SSI directives to be processed in a directory, the directory must be described in the access.conf file as Options Indexes Includes (or Options Includes), nested directories inherit the option and do not require a separate entry. Not everyone has access to this file, however, there is a general unwritten rule: on many hosts, the content is divided into 2 root directories: cgi-bin and WWW. In files in the cgi-bin directory, no files are (usually) checked for SSI instructions, and no files (even those included by ) are displayed in browsers. Therefore, a file that is a page fragment and included in it by the SSI directive should NOT be located in the cgi-bin directory cgi-bin can contain only cgi-scripts, since they are not included in the page directly (only the result of their execution is included).
  • SSI directives are processed not only in the files requested by the visitor, but also in the fragments included in them, if they have an extension for which checking for the presence of SSI directives is allowed. This can be used in various ways, in particular to handle the variables set on the page that includes these fragments.
  • Usually, any files in the WWW directory can be included using the SSI include directive, so the fragments themselves can be stored in files with any extension. However, it should be borne in mind that HTM and HTML files are indexed by search engines, which means that they can send the visitor to an incomplete fragment of the page (this, of course, is unlikely, since this fragment must have an indexed link), which, in turn, may disappoint him and push him away from the site. There are several ways to avoid such an annoying curiosity:

Scope of SSI.

Usually SSI is used where Frame, Object, Script src=, etc., for example, to include repeating fragments (menus, banner codes, headings) in a WEB page. However, the activation mechanism is completely different. If in Frame, Object, Script src=, etc., the included file is simply issued by the server and inserted in place by the user agent (browser), then in the case of SSI, the browser receives the page in a ready-made form. The inclusion occurs directly on the server, and this gives rise to the following differences:

  • When including the Frame type, Object, Script src=, etc., the visitor can find out the source code of the page, but when SSI-enabling not. Hiding the source code may be useful to the author.
  • When including the type Frame, Object, Script src=, etc., the logical completeness of the included objects is required, but not with SSI injection. It can also be convenient, as it allows you to split the page into arbitrary fragments and allocate more common places to separate files.
  • When including the type Frame, Object, etc., an object in the included fragment can be referred to as FRAGMENT_NAME.OBJECT_NAME, and an object embedded by an SSI instruction as a normal page element so much easier.
  • When including the type Frame, Object, etc., you can allow the user to change the contents of objects, but not with SSI injection. This significantly narrows the scope of SSI.
  • When you include the Frame type, Object, Script src=, etc., the processing of conditions and other directives occurs on the visitor's computer, and with SSI on the server. Thus, the SSI technology slows down loading: the gain is achieved only if large fragments are either turned on or not turned on, depending on specific conditions (then, although the load on the server processor increases, the load on the communication line decreases).
  • Since SSI is performed by the server, the true appearance of the page can only be seen there, which is not convenient. Programs that allow you to get SSI on a local computer do not give exactly the same option, at least due to the difference in type variables DOCUMENT_URI. And taking into account the direct settings of each specific server, the difference can be of fundamental importance.
  • When including the type Frame, Object, Script src=, etc., the included object is loaded only once and, on subsequent inclusion, is taken from the cache. With SSI injection, the fragment is loaded with each new page, slowing down the loading SIGNIFICANTLY: This is already quite bad.
  • When including the Frame type, Object, Script src=, etc., the menu is in one file, and with SSI, it is embedded in every page, thereby dispersing the internal link value, and spoiling the whole thing when you want to focus all the link weight on main page.

What to use: Frame, Object, Script src= or SSI is up to you.

Include file foot.htm:

The practical difference between the same page built using different technologies is that each page of IFRAME technology objects looks more complete and is completely independent. This slightly increases the load time of the first page, but due to caching, repeated fragments do not have to be loaded with the next page and further loading is significantly accelerated (for more on the benefits of Frame, see “If you don’t like frames, then you don’t know how to prepare them”) . The combination of two switching technologies gives the highest quality result. It applies to all professional sites and, if Frame and Object may not meet somewhere, then at least Script src= and (the same inclusion of code contained in a separate file and loaded only once) is used everywhere.

The use of IFRAME cannot completely replace SSI, since SSI allows not only loading fragments by condition (which can be solved with a script), but also, as shown in the example, passing any parameters to them through variables. Without SSI, this can only be done using the POST method or via HTTP_REFERER (the continuation of the file name, after the question mark), for further processing by some script. But the possibilities of such transfer do not go to any comparison with the possibilities of transferring the values ​​of SSI variables. Therefore, the use of SSI may be required even on pages based on frames the more tools available to us, the better and faster the result.

What ssi and what do they eat it with?

Server Side Include (SSI).This thing in WWW-design is extremely necessary and useful, as it greatly facilitates the work of creating and maintaining a Web site.

Server Side Include is translated from English as "included on the server side". This technology allows the Web server to include any other text in the text of your HTML pages: the contents of text files or, for example, the result of CGI scripts (which, as you know, usually formatted as HTML). This "switching on" occurs just before the HTML page text is passed to the user's browser, so that the page visitor is not even aware of this server "fuss".

What is the use of SSI? The benefit is huge. Suppose, on each page of your site, you have placed a list of available sections of the site. Your creation, as it should be, is constantly evolving, and so you decided to add another section. What now, open all the pages in the editor and stupidly add the same thing to the text? A Soviet pioneer (who loves challenges) would do just that, and a smart Web designer would use SSI. To do this, it is enough to create a separate text file (for example, menu.html) and enter the HTML code of the sections list there. Directly into the pages of the site, in the place where the list of sections should be, you need to insert the following instruction:
Note that the syntax of the SSI directives must be followed verbatim. Forget, for example, to put two dashes at the end of the directive - and the server will literally "choke" on it, stopping parsing the page.

When someone wants to view this page, the server will replace the instruction<#include>the contents of the menu.html file. If you change the menu.html file, then all the pages where you used<#include>will update automatically. Note that nothing changes in the HTML files on the Web server's disk - the server inserts the text on the fly before sending the WWW page to the visitor's browser.

Instead of a plain text file name in the instruction<#include>you can specify the name of the CGI script. In this case, the server will first execute the CGI script, and then insert the result of the script into the text of the WWW page. This means that you can implement things like a text-based hit counter or displaying a randomly selected phrase on the page.

There is another indirect benefit of using SSI: because of the use of templates like menu.html mentioned above, WWW pages will be smaller in size, and you can save a lot of time by transferring files to a Web server via FTP.

But not everything is so great. For example, you won't be able to experiment with the SSI mechanism on a machine that doesn't have a Web server installed. SSI functionality is provided by the server, so when viewing HTML files from a local hard drive (for example, C:), your browser will ignore SSI directives - after all, they are ordinary comments from the HTML point of view.

In addition, the server must be configured to support SSI. And there are such greedy providers who begin to demand money for such a setting. It is best not to use their services, since SSI support is enabled by adding a couple of lines to the Apache Web server configuration files and some other simple administrator actions, for which it is a sin to charge money, in my opinion.

Fortunately, there are not very many such providers. Most offer SSI support by default. But keep in mind that on free servers such as Hoom, Tripod, Geocities, Chat.ru SSI is not allowed. Nothing can be done about it :-(

Speaking of server settings. When SSI support is enabled, the server starts to scan all pages for the presence of SSI directives, which increases the load on the server. Therefore, very often system administrators enable SSI only for files with a specific extension - usually .shtml. So if SSI does not work in .html files, try renaming them to .shtml, or better ask your system administrator about it :-)

All in all, SSI is a really useful tool that should not be ignored if you value your time (and money).

What is SSI and what is it eaten with II

With this article I would like to open a new subsection on DVK URL CLUB. "Your column" is designed to collect materials and opinions of our visitors. The first article was written by our moderator of the "Smoke Break" section based on one of the topics on "Smoke Break", in which Alexander explains some of the features of using SSI directives. The author also wants to remind you that SSI instructions can only be used on a server that supports them. Most of the free web hosts don't have this feature and simply don't support SSI.

Preamble
The essence and the simplest techniques in SSI have already been described on this site. As a rule, at the collapse of articles on mastering, you rarely find anything other than a description of a single "include" function in the simplest version.

However, SSI can be safely called a programming language, if not a full-fledged one, but a language. SSI allows you to define conditions and variables, and also knows how to work with so-called environment variables, one of which is $QUERY_STRING, which is actively used when programming in Perl, PHP, and other server scripting languages. This is where the fun begins.

The essence of the phenomenon or the result that the Webmaster has.
By and large, we will now talk about templates. At the next update, it will be enough for the person maintaining the site to add a link to the new page in the table of contents and create a file with plain formatted text without any markup. Agree that it is very convenient :)

Technology: Conditional directives and $QUERY_STRING environment variable.
In general, there is some kind of index.shtml template, which is the following:

:: Title, damn it::



... Cool tags and cool graphics...

Here, in principle, problems with understanding should not arise, but further - the most interesting. Let me explain that the value of the $QUERY_STRING variable is determined by the content of the query string after the "?" sign, i.e. http://maste.ru/section/index.shtml?page1.
second and key part:



I think decryption is needed. We have five directives, of which three are conditional and two are normal includes:
The contents of the query string are checked for the presence of the "?something" construct, and if the result is positive, the second directive is executed.
A file with a name identical to the contents of the string is connected, for example, if the query string looks like this: "http://maste.ru/razdel/index.shtml?page1", then the file "page1.txt" is connected, which lies in the same directory as the index file.
It is executed if there is no content like "?something" in the string, and the URL looks like this: "http://maste.ru/razdel/index.shtml" or like this: "http://maste.ru/razdel/ ", and proceeds to the execution of the fourth directive.
The file is connected by default, containing, as a rule, the table of contents of the section, i.e. links to section files, which should look like this: link to page number 1, etc.
Completion of the condition.
Next comes the count of the bottom of the html code:
... some more Cool tags and cool graphics...


How will it work?
The following files are dumped into the folder:
index.shtml (terminal type);
default.txt (list of links page 1 and te de and te pe and hetetepe:);
files page1.txt, ..., page571756.txt until you get bored (in principle, the name can be anything, the main thing is that it matches the content after the "?" in the corresponding link).
If you intend to use SSI directives inside ordinary files, then it is better to do them in the same way .shtm, .shtml, and do not forget to correct the extensions in the code of the index.shtml file.

Here! Use on health :)








2022 gtavrl.ru.