- Address Books & Journals
- Art & Architecture
- Audio CDs
- Audio Cassettes
- Biography
- Business & Finance
- Calendars
- Children's Books
- Comics & Graphic Novels
- Computers & Internet
- Crime, Thrillers & Mystery
- Education & Languages
- Fiction
- Food & Drink
- Gay & Lesbian
- Health, Family & Lifestyle
- History
- Home & Garden
- Humour
- Law Books
- Mind, Body & Spirit
- Music, Stage & Screen
- Photography
- Poetry, Drama & Criticism
- Reference
- Religion & Spirituality
- Romance
- Science & Nature
- Science Fiction & Fantasy
- Scientific, Technical & Medical
- Society, Politics & Philosophy
- Sports, Hobbies & Games
- Travel & Holiday
Are you an interested in planning to start an online business or do you just want to start an online shop ? Peter Kent and Jill K Finlayson, in their top selling book “How to Make Money Online with eBay, Yahoo!, and Google” (ISBN: 978-0072262612), introduce you to a step-by-step plan to generate revenue online and maximize profits. It helps you reach targeted buyers using strategic search engine placements ....

Author: Rich BowenKen Coar
ISBN: 0596529945
EAN: 9780596529949
2. Edition
306 Pages
Publisher: O'Reilly Media, Inc.
Binding: Paperback
Publication date: 2007-12-21
| shop | cond. | avail. | price | delivery costs | total | |
![]() | USED* | ![]() | starting at £2.40 | Buy now | ||
![]() | NEW | ![]() | £ 2.75 | Buy now | ||
![]() | USED | ![]() | £ 2.75 | Buy now | ||
![]() | NEW | ![]() | free on orders over £ 5 | Buy now | ||
![]() | NEW | ![]() | free on orders over £ 19 | Buy now | ||
![]() | NEW | ![]() | free on orders over £ 5 | Buy now | ||
![]() | NEW | ![]() | free on orders over £ 20 | Buy now |
Ken Coar is a member of the Apache Software Foundation, the body that oversees Apache development. He is the author of "Apache Server for Dummies" and co-author of "Apache Server Unleashed" (Sams). Ken is responsible for fielding email sent to the Apache project; his experience with that mailing list provided a foundation for this book. Ken is a resident of Raleigh, North Carolina.
When you?re running a web site, things go wrong. And when they do, it?s important that they are handled gracefully, so that the user experience is not too greatly diminished. In this chapter, you?ll learn how to handle error conditions, return useful messages to the user, and capture information that will help you fix the problem so that it does not happen again.
9.1 Handling a Missing Host Field
Problem
You have multiple virtual hosts in your configuration, and at least one of them is name-based. For name-based virtual hosts to work properly, the client must send a valid Host field in the request header. This recipe describes how you can deal with situations in which the field is not included.
Solution
Add the following lines to your httpd.conf file:
Alias /NoHost.cgi /usr/local/apache/cgi-bin/NoHost.cgi
RewriteEngine On
RewriteCond "%{HTTP_HOST}" "^$"
RewriteRule "(.*)" "/NoHost.cgi$1" [PT]
The file NoHost.cgi can contain something like the following:
#! /usr/bin/perl ?Tw
my $msg = "To properly direct your request, this server requires thatn"
. "your Web client include the HTTP 'Host' request header field.n"
. "The request which caused this response did not include suchn"
. "a field, so we cannot determine the correct document for you.n";
print "Status: 400 Bad Requestrn"
. "Content-type: text/plainrn". 'Content-length: ' . length($msg) . "rn"
. "rn"
. $msg;
exit(0);
Discussion
Once the directives in the solution are in place, all requests made of the server that do not include a Host: field in the request header are redirected to the specified CGI script, which can take appropriate action.
The solution uses a CGI script so that the response text can be tailored according to the attributes of the request and the server?s environment. For instance, the script might respond with a list of links to valid sites on the server, determined by the script at runtime by examining the server?s own configuration files. If all you need is a "please try again, this time with a Host: field" sort of message, a static HTML file would suffice:
RewriteRule .* /nohost.html [PT]
A more advanced version of the script approach could possibly scan the httpd.conf file for ServerName directives, construct a list of possibilities from them, and present links in a 300 Multiple Choices response. Of course, there?s an excellent chance they wouldn?t work, because the client would still not be including the Host: field.
9.2 Changing the Response Status for CGI Scripts
Problem
There may be times when you want to change the status for a response?for example, you want 404 Not Found errors to be sent back to the client as 403 Forbidden instead.
Solution
Point your ErrorDocument to a CGI script instead of a static file. The CGI specification permits scripts to specify the response status code.
In addition to the other header fields the script emits, like the Content-type: field,
include one named Status: with the value and text of the status you want to return:
#! /bin/perl -w
print "Content-type: text/html;charset=iso-8859-1rn";
print "Status: 403 Access deniedrn";
:
Discussion
If Apache encounters an error processing a document, such as not being able to locate a file, by default it will return a canned error response to the client. You can customize this error response with the ErrorDocument directive, and Apache will generally maintain the error status when it sends your custom error text to the client.
However, if you want to change the status to something else, such as hiding the fact that a file doesn?t exist by returning a Forbidden status, you need to tell Apache about the change.
This requires that the ErrorDocument be a dynamic page, such as a CGI script. The CGI specification provides a very simple means of specifying the status code for a response: the Status: CGI header field. The Solution shows how it can be used.
similar books
last viewed books
|
|
|
||||||
|
|
|
Contact / About us
Bookmark this page
Home
Tell A Friend























