You can take a look at Apache's Rewrite module and SSI (Server Side include). =================================== ====================================== SSI
Have you ever done in how you can complete the changes to a website containing thousands of pages in the shortest time? So you can look at this article, perhaps you can help you. What is SSI? SSI is the abbreviation of English Server Side Includes, translated into Chinese is the meaning of the server side. From a technical point of view, SSI is an HTML file, which can be called or pointers through the comment line. SSI has a powerful feature, as long as a simple SSI command can realize the content update, dynamic display time and date of the entire website, and perform complex features such as Shell and CGI scripts. SSI can be said to be the best helper for website developers who have a shortage of funds, time, and workload. SSI is initially launched on the NCSA server platform, which is expanded and enhanced in the Apache server, which is now running on almost all servers. This article will mainly bind to the APACHE server to introduce the use of SSI. How to start SSI? Under the Apache server, you can create a .htaccess file to start SSI by direct editing the server profile or in a directory you need to use the SSI. Specifically, the process is as follows: 1. Server profile If the user has access to the server profile, the SSI can be launched by editing file access.conf and srm.conf. First use the Telnet remote login server to find the storage directory of the configuration file. In general, the configuration file of the Apache server is saved in the / usr / local / etc / httpd / confal directory. Use any text editor to open the file SRM.CONF, find the following lines: # if you want to use server side incduDes, or cgi outside # scriptaliased directories, uncomment the following lines. #Addtype text / x-server-parse HTML.SHTML # addtype application / x-httpd-cgi .cgi may not have the above note instruction line, but simply find two rows starting with ADDTYPE and remove the "#" symbol of each row. Save the modifications made, then open the file access.conf. Users need to find some of the part of setting the DocumentRoot (root file) in the file. It is generally said that the text is as follows, but it does not exclude the
Note that the file name must have a symbol "." So the server can know that the file is hidden file, thereby increasing the security of the file, avoiding error operations. In the .htaccess file, you need to add the following three lines of text: Options indexes backsymlinks include addtype application / x-httpd-cgi .cgi addtype text / x-server-pased-html .shtml can then transfer .htaccess file to the server. Directory, this file is valid for all subdirectories. If the user wants to disable the CGI or shell command on the directory level, you can add keyword incrudesnoexec on the .htaccess file. 3. Use .shtml or .html? Any file containing SSI must pass the server's parsing process before it is submitted to the client. Although a server's load is increased to some extent, the performance of a server does not have a significant decline unless a user's website has millions of access users every day. However, if it is not necessary to use SSI in each page, it is indeed necessary to let the server parses each page. If the user only wants to use SSI to use SSI in several special pages, you can change the file's suffix name to .shtml, so that the server can only resolve the .shtml file containing the SSI. On the other hand, if there is a plurality of pages that use SSI, but the user does not want to use .SHTML's suffix name, you can use the following command line in .htaccess file: addtype text / x-server-pased-html .htmlssi syntax SSI Follow the following format: where Directive is the instruction name sent to the server, parameter is the operation object of the instruction, and the value is the instruction processing result of the user wants. . All SSI commands start with "". The SSI command contains six types of instructions and their respective parameters, as follows: Directives Parametersconfig errmsg, timefmt, sizefmtinclude virtual, fileecho varFSize FileFlastMod FileExec CMD, CGI below We will introduce one by one. 1.config command The config command is primarily used to modify the default settings of the SSI. Where: errmsg: Sets the default error message. In order to be able to return the user setting error information, the errmsg parameter must be placed in front of the other SSI command in the HTML file, otherwise the client can only display the default error message instead of the custom information set by the user. timefmt: Define the date and time of the time pattern. Timefmt parameter must be used before the echo command.
display result is: Wednesday, April 12, 2000 maybe user The% a% B% D used in the above example is very unfamiliar. Below we will summarize some of the commonly used date and time format in the SSI in the form of a table. Format Description Instance %% %% A week seven days of abbreviation Form THU% a week seven days thursday% B months Abbreviation Form APR% B Apr Min 1 month 13% D MM / DD / YY Date Format 04 / 13/00% h hours (24-hour system, from 00 to 23) 01% i hour (12 hours, from 00 to 11) 01% J, from 01 to 365 104% M within one year The first few minutes from 01 to 1204% M, from 00 to 59 10% P AM or PM% R 12 hourly system, format 01:10:18 AM% I:% m:% s AM | PM% S in the first few seconds, from 00 to 59 18% T 24 hour% h:% m:% s time format 01:10:18% U The first day of the week, from 00 to 15 52, as the first day of each week in Sunday, the first day of each week, from 0 to 6 4% W Year a year, from 00 15 Between 53, as the first day of each week as the first day of each week, the four digits from 00 to 99 00% Y, a four-digit number representing a year 2000% z time zone name MDTSIZEFMT: Deciding the file size is byte, The kilobyte is also a megabyte means. If in bytes, the parameter value is "BYTES"; the abbreviated form can be used for kilobytes and megabytes. Similarly, the SIZEFMT parameter must be placed in front of the fsize command to use.
The 2.include command The include command can put the text or image in other documents into the currently resolved document, is the key to the entire SSI. You can instantly update the entire site instantly through the incrude command. The include command has two different parameters. If you update the site with the wrong parameter, you will not only get the original intention, but it will get a lot of error messages. Virtual: Gives the virtual path to a document to the server. For example: In order to more reasonable organizational sites, users can create an incutes subdirectory in the root directory to store all of the included files. The Virtual parameter can notify the server to include a virtual file, that is, the file and the currently parsed document are not in the same directory, but stored in other directories. The server finds the incrudes subdirectory in the root directory based on the value of this parameter. Using this method, users can put all the files contained in all HTML documents in a directory, and save different pages in different directories or subdirectories, depending on each other. Regardless of the server resolves which documentation can find the files contained without any errors. However, there is a small problem to solve it here. Generally we join some Title and Meta tags in the page. If we specify that all pages call the same header file, it is very unflexible. When the user encounters such a problem, you can use two containing files, one settings before setting the Title tag, and the other after setting the META tag, and any custom content can be added between the two containing files. For example:
For example, if we don't want a person who is not familiar with HTML directly to change the news page in the website, you can only update a separate text file, and then contain this file into the HMTL document, so you won't damage it. Original page, at the same time updated, the two all its beauty 3.echo: echo command can display the following environment variables: Document_name: Displays the name of the current document. The result is: index.htmldocument_uri: Displays the virtual path of the current document. For example: The result is: /yirateDirectory/yourfilename.html With the continuous development of the website, those increasingly long URL addresses will definitely make people a distress. 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, ie: http:// youriMain query_string_unescaped: Show uncontrolled processed by customers The query string sent by the end, where all of the special characters have escape characters "/". For example: Date_local: Displays the date and time of the server setting time zone. The user can customize the output information in conjunction with the TIMEFMT parameters of the config command. For example: The result is: Saturday, The 15 of April, in the year 2000date_gmt: The function is the same as Date_Local, but returns to the date based on the Greenwich time. For example: Last_Modified: Displays the last update time of the current document. Similarly, this is a very practical feature in SSI, as long as the following simple text is added to the HTML document, you can update the update time on the page. CGI Environment Variable In addition to the SSI environment variable, the echo command can also display the following CGI environment variables: Server_software: Displays the name and version of the server software. For example: Server_name: Displays the host name, DNS alias or IP address of the server. For example: Server_Protocol: Displays the protocol name and version used by the client request, such as HTTP / 1.0. For example: Server_port: Displays the server's response port.