perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Tompkins" <>
Subject Re: Multiple Sites
Date Tue, 04 Dec 2001 18:15:23 GMT
It rather sounds to me that you have a TransHandler that needs some
polishing. The translation handler should inspect for the resolved path
being a directory.  If it is a directory and the requested uri is lacking a
trailing forward slash then it needs to issue a redirect with the trailing
slash as mod_dir would have done.  If the resolved path is a directory and
the uri includes the trailing forward slash, then you'll need to resolve the
index file.

It is possible, however, to run some preliminary translation on the uri --
pulling out and noting interesting things from the uri -- and then DECLINE
the request to allow Apache's translations to finish resolving the request
to a file.  Here's an example of this:

package My::Apache::TransHandler;

use strict;
use Apache::Constants qw(:response);

sub handler {
    my $r = shift;

    # Assuming a pipe delimited list of virtual directories
    # set these in httpd.conf like this:
    # PerlSetVar VirtualDirectories "dir1|dir2|dir3|dir4"

    my $virtual_dirs = $r->dir_config('VirtualDirectories');

    if ( $r->uri =~ m!^/($virtual_dirs)$!o ) {
        # virtual directory only, no trailing slash
        $r->header_out( Location => $r->uri . "/" );
        return REDIRECT;

    # see if the uri contains the prefix
    if ( $r->uri =~ m!^/($virtual_dirs)/(.*)!o ) {

        # save the virtual path in $r->notes
        $r->notes('VIRTUAL_PATH' => $1);

        # reset the uri to everything following the virtual directory
        # you may want to change this in some other way
        $r->uri( "/$2" );


    # if you want apache to finish resolving the uri to a file...
    return DECLINED;

    # otherwise, add code to resolve to the file



NOTE: I've not tested the above code, so it could contain errors.


Tim Tompkins
----- Original Message -----
From: "Purcell, Scott" <>
To: <>
Sent: Monday, December 03, 2001 11:12 AM
Subject: Multiple Sites

I have the need to create 10 web sites off my Apache web server. I do not
want to use 10 IP addresses. So I am doing to cheeze and do a
URL/directory/index.html foreach site.

Then I would give each customer a URL of URL/directory and I would like the
index.html or the default.html to come up. But it does not.
I edited my conf file to this
<IfModule mod_dir.c>
#    DirectoryIndex index.html
    DirectoryIndex default.htm


But but it does not work. But if I put in URL/directory and a forward slash/
eg. http://URL/directory/ then it shows the default.htm page. But I know my
customers, and they will not put in the directory forward slash. How do I
get around this issue?


Scott Purcell

View raw message