SSI use details

xiaoxiao2021-03-06  66

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 and tags and other settings. # This kind be changing to wherever you set documentroot to. # this may also be "none", "all", or any combination of "indexes", # "incrudes" OR "FOLLOWSYMLINKS" OPTIONS INDEXES FOLLOWSYMLINKS INCLUDES If the user does not want the script or shell command, you can add keyword INCLUDESNOEXEC in the Options option row, which allows SSI, but cannot perform the CGI or script command. (Note: The latest version of the Apache server has only one profile httpd.conf, and the content mentioned above has been included in this file) 2. Create a file .htaccess If the user cannot directly access the server configuration file, you can use file editing Create a file called .htaccess.

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: Your page title </ title> <link rel = stylesheet href = "http://domain.com/styles/my .css "type =" text / css "> <meta name =" description "content =" description of page "> <meta name =" keywords "content =" keywords for point "> <! - # include virtual =" / Includes/header2.html "-> Set the page content <! - # CLUDE VIRTUAL =" / INCLUDES / FOOTER.HTML "-> From the top we can see that the header and footer can be included in the page Greatly reduce the workload of site updates. But if we want to dynamically display some content, such as what should I do if the last update time of the page is? No problem, we can save the included files using the .html suffix, so you can call other included files in the included file. File: Give the relative path to the current directory, where "../" cannot be used, and the absolute path cannot be used. For example: <! - # include file = "header.html" -> This requires all of the header.html files in each directory. Of course, this method is not more simple than updating each page, but if the user updates one, the two files are still very convenient.</p> <p>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. <! - # echo var = "Document_name" -> The result is: index.htmldocument_uri: Displays the virtual path of the current document. For example: <! - # echo var = "Document_uri" -> 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 <! - # echo var = "document_uri" -> 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: <! - # echo var = "query_string_unescaped" -> 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: <! - # config timefmt = "% a, the% d of% b, in the year% y" -> <! - # echo var = "date_local" -> 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: <! - # echo var = "date_gmt" -> 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. <! - # echo var = "last_modified" -> 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: <! - # 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.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-106592.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="106592" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.036</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'r1r_2FN1U_2BcrhQisT1OEirrxIZ7cIE7sNmUGtX2Aie3JCRK4zVya3PNDxwgNXo5oKpIGa9E1aLTEeIIxkHdB_2Bhxw_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>