063 066




Apache Server for Windows Little Black Book:Organizing Your Web Site
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




Immediate Solutions
Locating Your Web Server
As stated in Chapter 1, the default installation location for Apache is C:\Program Files\Apache Group\Apache. You can change to another location (such as C:\Apache) if you want to. Within the Apache directory are the directories conf, htdocs, cgi-bin, icons, logs, and modules.

The default location for your Web files—your document root—is htdocs. However, you might want to change this default arrangement. As an alternative, you can locate all of your Web-server files in a single branch of your computer’s file system and then move your document root and other Web directories within that new branch. This has a number of advantages:

•  It helps organize both your primary Web site and any virtual sites that either you or your clients set up.
•  It makes it easy for you to copy your whole set of Web files in case you need to back them up (which is always a good idea).
•  It facilitates copying everything to another machine in case you need to set it up as a server.

A possible arrangement of Web files is shown in Figure 3.4.


Figure 3.4  Arrange all your Web files under a single branch of your file system.
To set up this arrangement, follow these steps:


1.  Install Apache either in C:\Apache or C:\Program Files\Apache Group\Apache.
2.  Open Windows Explorer and click once on the Apache directory to select it.
3.  Choose File|New|Folder to create a new directory in Apache at the same level as htdocs, conf, bin, and so on.
4.  Enter “www” (or “web”, “html”, or another name) for the folder and press Enter.
5.  Click once on the folder you just created. Repeat Steps 3 and 4 twice to create two new directories, named public and private, within the www directory.
6.  Move cgi-bin and htdocs into public.
7.  Select the directory named private and repeat Steps 3 and 4 to create two new directories, htdocs and cgi-bin, within private.
8.  Open httpd.conf in Notepad.
9.  Change the argument for DocumentRoot to the path leading to htdocs, as in the following:


C:/Apache/www/public/htdocs


10.  Choose File|Save to save your changes.
11.  Choose File|Open and open srm.conf in Notepad.
12.  Change the ScriptAlias directive to point to the new location of cgi-bin. (See “Locating CGIs” later in this chapter; also see Chapter 7.)
13.  Choose File|Save to save your changes.

Figure 3.4 shows both the primary site www.company.com and client virtual site www.client.com as being under the same branch, www. The www.client.com site also includes a directory for an individual user. (See “Creating Personal Web Directories” later in this chapter.) Some sites use “web” for this branch’s designation, some “html.”
Creating Custom Error Messages
You’re probably very familiar with the standard HTTP error message and accompanying error codes that a server returns when it cannot comply with a request for some reason. An example is shown in Figure 3.5.


Figure 3.5  The generic error message isn’t very user friendly and can be customized.
By making use of Apache’s ErrorDocument directive, you can provide a more informative message. ErrorDocument takes the following syntax:


ErrorDocument <HTTP response code> <message|filename|URL>


The following steps show you one way to create a custom error document:


1.  Create an HTML document that contains your custom error message. You might, for instance, get some 404 “File Not Found” errors if your site moves from one location to another. In that case, you might name the file newaddress.html and provide a message like this:


"Sorry, you have tried to access a file from our old
Web site. We have moved to a new URL:
http://www.newsite.com. You'll probably find the file
you want there."


2.  Save your document and place it in your document root directory.
3.  Open srm.conf in Notepad.
4.  Scroll down to the ErrorDocument section of srm.conf and uncomment this line:


#ErrorDocument 404 /missing.html


5.  Change the line so it applies to your own error document, like this:


ErrorDocument 404 /newaddress.html


6.  Choose File|Save to save your changes.

You have several other options when it comes to creating custom error messages. Perhaps the easiest is to add your message directly to srm.conf, like this:



ErrorDocument 401 "Sorry, only subscribers are allowed access
to our site. It only takes a few minutes to subscribe. Go to
our home page and follow the instructions provided there."


Apache will not output the quotation marks when it displays this message.

You can also activate a CGI script in response to an error. Such a script might try to determine the cause of the error. In that case, you would use a call to the CGI script instead of a file name:


ErrorDocument 404 /cgi-bin/missingfile.cgi


You can also redirect the visitor to a different site by using a URL as the argument rather than a file name or CGI call:



ErrorDocument 404 http://www.backupsite.com/


However, you cannot redirect the client to a remote server in response to a 401 “Unauthorized” error. A 401 error must use a local file or a message.




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