SSI use details

xiaoxiao2021-04-05  271

SSI use details

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 incrudes, 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: Options indexes backsymlinks includedtype application / x-httpd-cgi .cgiadtype text / x-server-pased-html .shtml can then upload the .htaccess file to the corresponding directory of the server, 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: DirectiveSParametersconfig errmsg, timefmt, sizefmtincludevirtual, fileechovarfsizefileflastmodfileexecmmd, 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's abbreviation Form THU% A For a week. THURSDAY% B Month Abbreviation Form APR% B April% D 1 month 13% DMM / DD / YY Date Format 04 / 13/00% H hours (24-hour system, from 00 to 23) 01% i hour (12-hour system, from 00 to 11) 01% J, from 01 to 365104% m within one year For a few months, from 01 to 1204% M: from 00 to 5910% PAM or PMAM% R12 small local time, format% i:% m:% S am | PM01: 10: 18 AM% S for the first few seconds, from 00 to 5918% T24 hourly-made% h:% m:% s time format 01: 10: 18% u 10 months, from 00 to 52 In Sunday, as the first day of each week, the first day of each week, from 0 to 64% W, from 00 to 53, as a week in Monday as each week The abbreviation of 15% y years, from 00 to 9900% Y, four digits indicate a year 2000% z time zone name MDT SIZEFMT: Decision file size is byte, kiloby, or megabytes. 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.

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 content, two whole 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.html document_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 2000 date_gmt: The function is the same as Date_Local, but returns to the date based on the Greenwich standard 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.</p> <p>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 client host name that issues request information. <! - # echo var = "remote_host" -> remote_addr: Displays the client IP address that issues request information. <! - # echo var = "remote_addr" -> auth_type: Displays the authentication method of the user identity. <! - # echo var = "auth_type" -> remote_user: Displays the account name used by the user who is accessing the protected page. <! - # echo var = "remote_user" -> 4.fsize: Displays the size of the specified file, which can be customized in combined with the SIZEFMT parameter of the config command. <! - # fsize file = "index_working.html" -> 5.FlastMod: Displays the final modification date of the specified file, which can combine the TIMEFMT parameter control output format of the config command. <! - # config timefmt = "% a, the% d of% b, in the year% y" -> <! - # FlastMod file = "file.html" -> Here we can use FlastMod The parameter shows the update date of all links on a page. The method is as follows: <! - # 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 / annother_file.html "-> display result For: File April 19, 2000another File January 08, 2000 maybe some readers will think that both links are so complicated, and it is not convenient little. In fact, if there are 20 or more links on the page, and each link is regularly updated, you can see the role of using FLASTMOD to display the modification date. The 6.EXECEXEC command can perform the CGI script or shell command. The method is as follows: CMD: Use / bin / SH to perform the specified string. If the SSI uses the IncludeSnoExec option, the command will be blocked. CGI: Can be used to perform the CGI script.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-131981.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="131981" 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.052</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 = '5ruIms0zVui9EOa_2BjnwLzWXVr2ZUuUpn2UZIZlBdGV_2Bwk4y3fFB_2B34nCEwnClBF_2B8kgo4RQhyG5NoRyW'; 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>