Chapter 8. Users' own web pages

userdir_module. We will introduce the relevant module and the single command it provides.

Simple use. We will start with the simplest provision of users' personal web pages by loading the module and using it in its simplest form.

Complex use. We will then give an example of how it can be used to redirect lookups to an entirely different system.

The principle of this chapter is to provide your users with the ability to create their own web pages. The web pages may be located on the servers in question, or on a different server altogether. As ever, there is a module that provides the extra functionality. In the example below, we provides user pages in all the virtual hosts.

LoadModule      userdir_module /usr/lib/apache2/mod_userdir.so
UserDir         public_html

In this example, the command UserDir public_html causes any URL of the form http://server/~bob/path/name.html to correspond to a file ~bob/public_html/path/name.html. (In this filename the expression "~bob" means "the home directory of user bob" and is standard Unix notation. It is this that the URL notation is based on.

The directory name public_html is not fixed and can be modified. Furthermore, more complex mappings of username onto file name can be provided. Any instance of "*" in the "directory name" will be replaced with the user's ID.

If the directory name is actually a URL then, instead of the web server looking for a local directory, it responds with an HTTP redirection, pointing the web client at a new URL, typically on a different server.

UserDir argumentTranslated path
public_html~bob/public_html/alpha/beta.html
www~bob/www/alpha/beta.html
/var/www/users/var/www/users/bob/alpha/beta.html
/var/www/*/web/var/www/bob/web/alpha/beta.html
http://elsewhere/usershttp://elsewhere/users/bob/alpha/beta.html
http://elsewhere/*/webhttp://elsewhere/bob/web/alpha/beta.html
http://elsewhere/~*/http://elsewhere/~bob/alpha/beta.html

It is possible to give a sequence of targets to the UserDir command. In this case they will be searched in turn until one provides the server with the file or directory it is looking for. Only the last entry in the list is allowed to be a redirection to another server (i.e. a URL) because when the server reaches this one it sends back the redirection to the browser and never gets to discover if the file existed at the far end.

Note that the Apache user, wwwrun under SLES, must be able to read files if it is to serve them. If it can't read the files in a user's public_html directory then all this isn't going to work.