Logo address

{httpd.rewrite}

目次

2003/02/11 Update

Location

/sys/lib/httpd.rewrite

Function

This file has two roles:

Case study

In the explanation below we assume our domain name is:
	pegasus.goodwill.com
And we assume five persons:
	alice
	bob
	carol
	david
	emily

URI

First of all I would like to explain URI(URL) briefly.
URI of HTTP is defined as below:
	scheme://host[:port][/path][;params][?query]
where

User's document is conventionally expressed using the path that begin with ~user in URI, where user is a user name of the system. That is, ~user is expressed as a directory under document root of the host. However implementation need not keep ~user under document root. Rather it would be convenient to have user's document in the directory of the user.

/sys/lib/httpd.rewrite

The below is an example of /sys/lib/httpd.rewrite for our case study.
# pattern        replacement
http://car       */usr/carol/www
https://car      */usr/carol/https
/~david          http://www.eecs.harvard.edu/~david
/~emily         */usr/bob/www_removed
/private         https://pegasus.goodwill.com/private
/                */usr/bob/www
The lines in this file consist of two fields except comment line. Fields are separated by spaces.

The first field is a pattern of request. The request is limited only to http and https. host is the name of real host or virtual host. Note that host is not full name of the domain.


If the first field begin with / then the request is regarded as the request to real host or user. That is, we regard scheme://host[:port] is omitted, where host is the name of real host.

In second field:


Note that the second field that begin with / is not described here. I would like to examine the real needs before I specify such a field.

If the requested URI matches the first field, then we have two cases:

Understand the below:
Comparison is executed using the following rules:

Therefore a line with / as the first field must be placed at the end

If there is no field in /sys/lib/httpd.rewrite that matches with URI, then Pegasus examines the possibility that the request is to the user.

Web root for real and virtual hosts

Pegasus permit to have access control files and CGI files not only for real host but also virtual hosts. All the system users who publish web contents have a web root(we refer $web), and can have doc, etc and bin under the directory. doc is the place where document is located, etc is the place where access control files such as rewrite, allow, passwd and handler are located, and bin is the place where CGI files are located.
Pegasus set web root in /sys/lib/httpd.rewrite. For example, assume bob administrate the the document of real host and carol administrate the the document of virtual host car. Then web root is specified in the second field using * followed by the directory path like this:
http://car      */usr/carol/www
https://car     */usr/carol/https
/               */usr/bob/www
In this case, carol are given two web root /usr/carol/www and usr/carol/https for her virtual host car.
A system user alice can have their personal home page of URI:
	http://pegasus.goodwill.com/~alice
without setting in /sys/lib/httpd.rewrite if she has $home/web/doc. $home/web is her web root.


Note: name of virtual must be register to DNS

2003/02/11 Update

/usr/bob/www/etc/rewrite

File /usr/bob/www/etc/rewrite is read after /sys/lib/httpd.rewrite. Expression
/private		https://pegasus.goodwill.com/private
will be considered in $web/etc/rewrite.

Format of /sys/lib/httpd.rewrite

General rule

Meta symbols

Format of the first field

First field is one of below:
	1.  scheme://host[:port]
	2.  /path
where
Please follow the rule:

Format of second field

Second field is one of bellow:
	1.  scheme://hostdom[:port][/path][;params][?query]
	2.  */path
where