httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David S. Madole" <>
Subject Re: [users@httpd] mod_rewrite per-dir trailing slash problem
Date Thu, 11 Nov 2004 22:01:58 GMT
From: "André Malo" <>
> * "David S. Madole" <> wrote:
> > I seem to have encountered a problem with mod_rewrite following an
> > upgrade from 2.0.50 to 2.0.52.
> >
> > I have many .htaccess files similar to the following:
> >
> > RewriteEngine on
> > RewriteBase /test
> > RewriteCond %{SERVER_PORT} 80
> > RewriteRule (.*) https://%{SERVER_NAME}/test/$1 [redirect]
> >
> > In this case, the purpose is to redirect the user to an SSL version
> > the URI.
> >
> > The problem that I find is that this does not work properly for URIs
> > reference the directory itself without the trailing slash. It appears
> > that this was not handled correctly by mod_rewrite on 2.0.50 either,
> > it seems that mod_dir did a redirect before the URI ever got to
> > mod_rewrite and so it didn't matter.
> Hmm. You mean, mod_dir no longer redirects? Did you change _anything_
> besides the httpd version? Is it a vanilla httpd?

Actually, mod_dir does redirect, but only if mod_rewrite does not. If a
rewrite rule with [redirect] matches, that's the redirect that happens,
not mod_dir's.

Interestingly, if there is a rewrite rule that changes the URI but
without [redirect], the mod_dir redirect happens, and redirects based on
the original URI, not the rewritten one. The rewrite did occur
internally, though, as shown in the rewrite log.

Yes, httpd is vanilla, here is how I build it:

./configure                     \
  --prefix=$OPT                 \
  --libdir=$OPT/usr/lib         \
  --libexecdir=$OPT/usr/libexec \
  --sysconfdir=$OPT/etc         \
  --datadir=$OPT/var            \
  --localstatedir=$OPT/var      \
  --with-ssl=/usr/local         \
  --enable-proxy=shared         \
  --enable-proxy-http=shared    \
  --enable-auth_digest=shared   \
  --enable-deflate=shared       \
  --enable-expires=shared       \
  --enable-headers=shared       \
  --enable-rewrite=shared       \
  --enable-ssl=shared           \

This is exactly the same build script that I used on 2.0.50, nothing else

> > What happens is that the RewriteBase does not match the URI
> The rewritebase is not used to match the URI. It's used to prefix the
> mod_rewrite strips the path of the .htaccess file from the translated
> filename.

Yes, you are right, of course. That's what I meant. It still doesn't
match because of the trailing slash.

Perhaps the real problem I am having is more related to something
different in mod_dir, but I do suggest that the problem in mod_rewrite
needs to be fixed anyway. Since it is now possible to use DirectorySlash
to disable mod_dir, the the possibility of non-slashed directory paths
getting sent to mod_rewrite is real and it should handle them sanely.


The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message