Detailed explanation of SSI usage_PHP tutorial
Have you ever been or are you currently struggling with how to complete modifications to a website containing thousands of pages in the shortest possible time? Then you can read the introduction of this article, it may be helpful to you.
What is SSI?
SSI is the abbreviation of English Server Side Includes. Translated into Chinese, it means server side inclusion. Technically speaking, SSI is a command or pointer in an HTML file that can be called through a comment line. SSI has powerful functions. With a simple SSI command, you can update the content of the entire website, dynamically display time and date, and execute complex functions such as shell and CGI script programs. SSI can be said to be the best helper for website developers who are short of funds, tight on time, and have a heavy workload.
SSI was originally launched on the NCSA server platform, expanded and enhanced in the Apache server, and can now run on almost all servers. This article will mainly introduce the use of SSI based on the Apache server.
How to start SSI?
Under the Apache server, you can start SSI by directly editing the server configuration file or creating an .htaccess file in the directory where SSI needs to be used. Specifically, the process is as follows:
1. Server configuration file
If the user has access to the server configuration file, it can be started by editing the files access.conf and srm.conf SSI.
First, use Telnet to remotely log in to the server and find the directory where the configuration file is stored. Generally speaking, the configuration files of the Apache server are saved in the "/usr/local/etc/httpd/conf" directory. Open the file srm.conf using any text editor and find 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
The user’s configuration file may not have the above comment line , but just find the two lines starting with AddType and remove the "#" symbol at the front of each line.
Save the changes and open the access.conf file again. The user needs to find the section in the file where the DocumentRoot (root file) is set. Generally speaking, the text is as follows, but it is not excluded that there are other setting contents between the
# This should be changed to whatever you set DocumentRoot to.
# This may also be "None", "All" , or any combination of "Indexes",
Options Indexes FollowSymLinks Includes
If the user does not want to execute scripts or shell commands, the keyword IncludesNOEXEC can be added to the options line , which allows SSI, but cannot execute CGI or script commands. (Note: The latest version of the Apache server has only one configuration file httpd.conf, and the above mentioned content has been included in this file)
2. Create the file .htaccess
If Users cannot directly access the server configuration file. They can use a file editor to create a file called .htaccess. Note that there must be 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 and avoiding incorrect operations. 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
After completion, you can upload the .htaccess file to the corresponding directory on the server. This file is valid for all subdirectories. If the user wishes to disable CGI or shell commands at the directory level, the keyword IncludesNOEXEC can be added to the Options line in the .htaccess file.
3. Use .shtml or .html?
Any file containing SSI must go through the parsing process of the server before being downloaded to the client. Although this will increase the load on the server to some extent, unless the user's website has millions of users visiting it every day, the performance of a certain server will not decrease significantly. However, if you don't need to use SSI on every page, there is really no need to have the server parse every page. If the user only wants to use SSI in a few special pages, he can change the file extension to .shtml so that the server can only parse .shtml files containing SSI. On the other hand, if there are multiple pages using SSI, but the user does not want to use the .shtml suffix, the following command line can be used in the .htaccess file:
AddType text/x-server-parsed -html .html
SSI syntax
SSI follows the following format when used:
In order to organize the content of the site more rationally, users can organize the content of the site in the root directory Create the includes subdirectory to store all include files. The Virtual parameter can inform the server that what is to be included is a virtual file, that is, the file and the currently parsed document are not located in the same directory, but are stored in other directories. The server will find the includes subdirectory in the root directory based on the value of this parameter. Using this method, users can put all files contained in HTML documents in one directory, and save different pages in different directories or subdirectories according to their relationship. No matter which document the server parses, it can find the included files without generating any errors.
But there is a small problem that needs to be solved. Generally, we will add some TITLE and META tags to the page. If we stipulate that all pages call the same header file, it will be very inflexible. When users encounter such a problem, they can use two include files, one to set the content before the TITLE tag, and the other to set the part after the META tag, and any custom content can be added between the two include files. For example:
Place here Page content
From the above we can see that by including the header and page in the page Feet can greatly reduce the workload of site updates. But what if we want to dynamically display some content, such as the last updated time of the page? No problem, we can save the included file with the .html suffix, so that we can call other included files in the included file.
File: Give? The relative path of the current directory, in which "../" cannot be used, and absolute paths cannot be used. For example:
This requires each directory to contain a header.html file. Of course, using this method is not much simpler than updating every page, but it is still very convenient if the user only updates one or two files. For example, if we don't want someone unfamiliar with HTML to directly change the news page on the website, we can just let him update a separate text file and then include the file into the HMTL document, so that it will not break The original page and updated content at the same time, the best of both worlds.
3.Echo:
The Echo command can display the following environment variables:
DOCUMENT_NAME: Displays the name of the current document.
The displayed result is:
index.html
DOCUMENT_URI: Display The virtual path of the current document. For example:
The displayed result is:
/YourDirectory/YourFilename.html
As the website continues to develop, those longer and longer URL addresses will definitely cause headaches. If you use SSI, everything will be solved. Because we can combine the domain name of the website and the SSI command to display the complete URL, namely:
http://YourDomain
QUERY_STRING_UNESCAPED: Displays the query string sent by the client without escaping, in which all special characters are preceded by the escape character "". For example:
DATE_LOCAL: Displays the date and time in the server's set time zone. Users can customize the output information by combining the timefmt parameter of the config command. For example:
The displayed result is:
Saturday, the 15 of April, in the year 2000
DATE_GMT: The function is the same as DATE_LOCAL, except that it returns a date based on Greenwich Mean Time. For example:
LAST_MODIFIED: Displays the last update time of the current document. Again, this is a very solid rose capsule in SSI.
http://www.bkjia.com/PHPjc/445111.html

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



CrystalDiskMark is a small HDD benchmark tool for hard drives that quickly measures sequential and random read/write speeds. Next, let the editor introduce CrystalDiskMark to you and how to use crystaldiskmark~ 1. Introduction to CrystalDiskMark CrystalDiskMark is a widely used disk performance testing tool used to evaluate the read and write speed and performance of mechanical hard drives and solid-state drives (SSD). Random I/O performance. It is a free Windows application and provides a user-friendly interface and various test modes to evaluate different aspects of hard drive performance and is widely used in hardware reviews

foobar2000 is a software that can listen to music resources at any time. It brings you all kinds of music with lossless sound quality. The enhanced version of the music player allows you to get a more comprehensive and comfortable music experience. Its design concept is to play the advanced audio on the computer The device is transplanted to mobile phones to provide a more convenient and efficient music playback experience. The interface design is simple, clear and easy to use. It adopts a minimalist design style without too many decorations and cumbersome operations to get started quickly. It also supports a variety of skins and Theme, personalize settings according to your own preferences, and create an exclusive music player that supports the playback of multiple audio formats. It also supports the audio gain function to adjust the volume according to your own hearing conditions to avoid hearing damage caused by excessive volume. Next, let me help you

NetEase Mailbox, as an email address widely used by Chinese netizens, has always won the trust of users with its stable and efficient services. NetEase Mailbox Master is an email software specially created for mobile phone users. It greatly simplifies the process of sending and receiving emails and makes our email processing more convenient. So how to use NetEase Mailbox Master, and what specific functions it has. Below, the editor of this site will give you a detailed introduction, hoping to help you! First, you can search and download the NetEase Mailbox Master app in the mobile app store. Search for "NetEase Mailbox Master" in App Store or Baidu Mobile Assistant, and then follow the prompts to install it. After the download and installation is completed, we open the NetEase email account and log in. The login interface is as shown below

Cloud storage has become an indispensable part of our daily life and work nowadays. As one of the leading cloud storage services in China, Baidu Netdisk has won the favor of a large number of users with its powerful storage functions, efficient transmission speed and convenient operation experience. And whether you want to back up important files, share information, watch videos online, or listen to music, Baidu Cloud Disk can meet your needs. However, many users may not understand the specific use method of Baidu Netdisk app, so this tutorial will introduce in detail how to use Baidu Netdisk app. Users who are still confused can follow this article to learn more. ! How to use Baidu Cloud Network Disk: 1. Installation First, when downloading and installing Baidu Cloud software, please select the custom installation option.

MetaMask (also called Little Fox Wallet in Chinese) is a free and well-received encryption wallet software. Currently, BTCC supports binding to the MetaMask wallet. After binding, you can use the MetaMask wallet to quickly log in, store value, buy coins, etc., and you can also get 20 USDT trial bonus for the first time binding. In the BTCCMetaMask wallet tutorial, we will introduce in detail how to register and use MetaMask, and how to bind and use the Little Fox wallet in BTCC. What is MetaMask wallet? With over 30 million users, MetaMask Little Fox Wallet is one of the most popular cryptocurrency wallets today. It is free to use and can be installed on the network as an extension

Windows operating system is one of the most popular operating systems in the world, and its new version Win11 has attracted much attention. In the Win11 system, obtaining administrator rights is an important operation. Administrator rights allow users to perform more operations and settings on the system. This article will introduce in detail how to obtain administrator permissions in Win11 system and how to effectively manage permissions. In the Win11 system, administrator rights are divided into two types: local administrator and domain administrator. A local administrator has full administrative rights to the local computer

Detailed explanation of division operation in OracleSQL In OracleSQL, division operation is a common and important mathematical operation, used to calculate the result of dividing two numbers. Division is often used in database queries, so understanding the division operation and its usage in OracleSQL is one of the essential skills for database developers. This article will discuss the relevant knowledge of division operations in OracleSQL in detail and provide specific code examples for readers' reference. 1. Division operation in OracleSQL

Apple rolled out the iOS 17.4 update on Tuesday, bringing a slew of new features and fixes to iPhones. The update includes new emojis, and EU users will also be able to download them from other app stores. In addition, the update also strengthens the control of iPhone security and introduces more "Stolen Device Protection" setting options to provide users with more choices and protection. "iOS17.3 introduces the "Stolen Device Protection" function for the first time, adding extra security to users' sensitive information. When the user is away from home and other familiar places, this function requires the user to enter biometric information for the first time, and after one hour You must enter information again to access and change certain data, such as changing your Apple ID password or turning off stolen device protection.
