Apache and mod_rewrite

Apache and mod_rewrite

Post by Richard Horwoo » Tue, 18 Nov 1997 04:00:00



I am in need of some assistance with a nuisance 'feature' of
the apache web server that I am using.  I am using mod_rewrite to
rewrite URLs on the server with a similar setup to the following:

/users                  - The directory holding user directories
/users/<foo>/dev  - Directories containing libs and other
  ""    ""  /bin    - neccessary files for anon-style chrooted
  ""    ""  /etc    - ftp access to html area for user <foo>
 ...............
/users/<foo>/documents - Contains html files for each user.

I am attempting to use mod rewrite so that a request (for example)
for:

http://my.web.server.com/jimmy/<foo>

Is directed to the file /<DocumentRoot>/users/jimmy/documents/<foo>

This works _most_ of the time, but if a user creates a subdirectory
called <bar> under <foo>, while the url is written correctly and
returns the correct document, the "Location" in Netscape (and IE
I'm assuming, I don't use that browser if I can help it) shows:

http://my.web.server.com/users/jimmy/documents/<bar>

If you append a slash to the end of the URL this does not happen,
and all appears to be well.

This is apache 1.2.4 running under Solaris 2.5.1.  The rewrite
rules that I am using are:

RewriteRule     ^([^/]+)$       http://my.web.server.com/$1/        
[R,L]
RewriteRule     ^([^/]+)/$      users/$1/documents/     [L]
RewriteRule     ^([^/]+)/(.*)$  users/$1/documents/$2   [L]

Any suggestions on how to stop the URL showing up in the location would
be greatly appreciated, along with suggestions for improvements
to my regexes.

Please also cc any responses to my email.  I apologise if this is in a
FAQ
somewhere.  If that is the case, I have been unable to locate it.

Many thanks.

Richard.

--
._-=`=-_._-=`=-_._-=`=-_._-=`=-_._-=`=-_._-=`=-_._-=`=-_.

Systems Engineer                Voice: +61 3 9735 5355
Mondial Net Pty. Ltd.             Fax: +61 3 9735 5399