Pick a Free OS

User login

Navigation

Web server tutorial - Part 3

Customizable error response

Customizable error response, the Apache style, comes in three flavors:


1) Plain text

ErrorDocument 500 "The server made a boo boo.

Note: The (") marks it as text, it does not get output.


2) Local redirects

ErrorDocument 404 /missing.html to redirect to local URL /missing.html

ErrorDocument 404 /cgi-bin/missing_handler.pl

Note: You can redirect to a script or a document using server-side-includes.


3) External redirects

ErrorDocument 402 some.other_server.com/subscription_info

Note: Many of the environment variables associated with the original request will not be available to such a script.

The following directives modify normal HTTP response behavior.

The first directive disables keepalive for Netscape 2.x and browsers that spoof it. There are known problems with these browser implementations. The second directive is for Microsoft Internet Explorer 4.0b2, which has a broken HTTP/1.1 implementation and does not properly support `keepalive' when it is used on 301 or 302 (redirect) responses.

BrowserMatch "Mozilla/2" nokeepalive

BrowserMatch "MSIE 4.0b2;" nokeepalive downgrade-1.0 force-response-1.0

The following directive disables HTTP/1.1 responses to browsers, which are in violation of the HTTP/1.0 spec by not being able to grok a basic 1.1 response.

BrowserMatch "RealPlayer 4.0" force-response-1.0

BrowserMatch "Java/1.0" force-response-1.0

BrowserMatch "JDK/1.0" force-response-1.0

If the perl module is installed, this will be enabled.

<IfModule mod_perl.c>

Alias /perl/ /home/httpd/perl/

<Location /perl>

SetHandler perl-script

PerlHandler Apache::Registry

Options +ExecCGI

</Location>

</IfModule>

Allow http put (such as Netscape Gold's publish feature)

Use htpasswd to generate /etc/httpd/conf/passwd


You must unremark these two lines at the top of this file as well:

LoadModule put_module modules/mod_put.so

AddModule mod_put.c

Alias /upload /tmp

<Location /upload>

EnablePut On

AuthType Basic

AuthName Temporary