172 176




Apache Server for Windows Little Black Book:Using Server-Side Includes
function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) { var end = document.cookie.indexOf (";", j); if (end == -1) end = document.cookie.length; return unescape(document.cookie.substring(j, end)); } i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } var m1=''; var gifstr=GetCookie("UsrType"); if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; } document.write(m1+m2+m3);            Keyword Title Author ISBN Publisher Imprint Brief Full  Advanced      Search  Search Tips Please Select ----------- Components Content Mgt Certification Databases Enterprise Mgt Fun/Games Groupware Hardware IBM Redbooks Intranet Dev Middleware Multimedia Networks OS Prod Apps Programming Security UI Web Services Webmaster Y2K ----------- New Titles ----------- Free Archive To access the contents, click the chapter and section titles. Apache Server for Windows Little Black Book (Publisher: The Coriolis Group) Author(s): Greg Holden with Matthew Keller ISBN: 1576103919 Publication Date: 01/01/99 function isIE4() { return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') ); } function bookMarkit() { var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0"; parent.location.href=url; //var win = window.open(url,"myitk"); //if(!isIE4()) // win.focus(); } Search this book:  















Previous
Table of Contents
Next




To enable SSIs for all HTML documents contained in a particular directory, you have a couple of options. One is to include the relevant directives within a <Directory> block, as shown here:


<Directory C:/www/Apache/htdocs/ssi-enabled>
AddHandler server-parsed .html
Options Includes
</Directory>



TIP:  Because the server already knows that files ending in .html have the media (MIME) type “text/html”, you don’t need to use the AddType directive.

Alternatively, you can put the directives into an .htaccess file in the directory where the documents are stored (or in a container directory). If you use this second method, both the directory that holds the files and the .htaccess file must be within the scope of an enabled FileInfo override for the AddHandler directive and an Options override for the Options directive. Follow these steps:

1.  Open srm.conf or another configuration file in Notepad.
2.  Enter the following:


<Directory C:/www/Apache/htdocs/ssi-enabled>
AllowOverride FileInfo Options
</Directory>


3.  Choose File|Save to save your changes.
4.  Choose File|New to open a new blank document that will serve as your .htaccess file and enter the following:


AddHandler server-parsed .html
Options Includes


5.  Choose File|Save and save the file with the name .htaccess.txt in the directory in which you want to enable SSI commands.

The advantage to using an .htaccess file is that the altered settings take effect at once. If AddHandler and AddType are in the server config files, they only take effect on server reload.
If you want to enable SSI for a virtual host site, for instance, you might enter the following in one of the configuration files:


NameVirtualHost 100.100.100.1

<VirtualHost www.acme.com>
ServerName www.acme.com
DocumentRoot c:/www/Apache/htdocs/acme
ServerAlias www.acmeinc.com
<Directory c:/www/Apache/htdocs/acme/ssis>
AddHandler server-parsed .shtml
AddType text/html .shtml
Options +Includes
</Directory>
</VirtualHost>


If you want to enable SSIs anywhere on your server, you only have to uncomment the lines in srm.conf:



#AddType text/html .shtml
#AddHandler server-parsed .shtml


This is probably only advisable for test purposes, however, because SSIs do pose a security risk and are best enabled in a specific <Directory>, <VirtualHost>, or <Files> container.
Using The XBitHack Directive
The XBitHack directive is the only directive provide by the mod_ include module. This directive enables the server to parse ordinary HTML Web pages that have the MIME-type text/html. XBitHack takes this syntax:


XBitHack status


Status can be set to on, off, or full:

•  off—This is the default value. Apache will not parse files in a scope covered by XBitHack.
•  on—This tells Apache that any HTML file that is included in the scope covered by XBitHack will be parsed as an SSI file—whether it includes SSI commands or not.
•  full—This tells Apache to check the owner and group executable bits of the file permission settings—but they are applicable under Unix and not relevant for Windows users.

The Apache Group discourages use of the XBitHack directive because it enables users to change the permissions levels of Unix files easily. For Windows users, this is irrelevant. As an alternative to XBitHack, you can tell Apache to parse conventional .html files by including the following in the appropriate scope:


AddHandler server-parsed .html
Options Includes


This is explained in the preceding section, “Specifying A Handler And File Type.”

Using The SSI Variables
To parse and process SSI commands, the server has to evaluate the HTML source code. To tell the server what to do with the source commands, mod_include provides a set of variables. They are in addition to all of the CGI program environment variables, which are also included in the SSI processing environment.

The SSI-specific variables are printed by using the echo command, following these steps:

1.  Using Notepad or a Web-page editor, open the HTML for the Web page to which you want to add the SSI command.
2.  Add SSI commands to the HTML, such as the following:


<!--#echo config timefmt="%Y-%m-%d" -->
<!--#echo var="LAST_MODIFIED" -->


This prints the date when the Web page was last modified, using the format specified by config timefmt:


1998-11-11


3.  Save the Web page in a directory in which you have enabled SSIs.

The SSI-specific variables are as follows:


•  DATE_GMT—The current date in Greenwich Mean Time. This is subject to the current time display format specified with config timefmt.
•  DATE_LOCAL—The current date in the local time zone (local to the server, that is, not to the client). This is also converted according to config timefmt.
•  DOCUMENT_NAME—The file name (excluding any parent directories) of the document requested by the client.
•  DOCUMENT_URI—The URI path of the document requested by the client. Any URI encoding has been decoded (for example, %2F replaced with /, %20 replaced with a space, and so on).
•  LAST_MODIFIED—The last modification date of the document requested by the user, presented in the format specified by config timefmt.

Each one of the preceding variables is set when the server begins to parse the main document requested by the client.




Previous
Table of Contents
Next






Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.



Wyszukiwarka

Podobne podstrony:
172 176
172 03 (2)
172 13 (5)
SHSpec 172 6207C19 The E Meter
172 193
172 08 (2)
Globo 172 Coluna China II(m)
176 177
172 12 (3)
172 04 (3)
16 (176)

więcej podobnych podstron