httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yves Goergen <>
Subject [users@httpd] mod_rewrite problem
Date Sat, 04 Aug 2007 16:19:59 GMT

I'm using mod_rewrite to correct some URLs on my web server, running
Apache 2.0. But I have a strange problem with it. First, here's the
rules I have set:

    SetEnvIf Host .+
    SetEnvIfNoCase Host ^beta\.unclassified\.de$ !desired_hostname

    RewriteCond %{ENV:desired_hostname} !^$
    RewriteRule ^(.*) http://%{ENV:desired_hostname}/$1 [L,R=301]

This is from the file .htaccess in the "beta" directory under, which is also the document root of

It first checks whether the page was requested through the wrong domain.
If so, the environment variable desired_hostname is set to where the
visitor should be redirected. The second part then redirects the URL
relative to the current directory as-is only over to the right domain.

This seems to work fine with non-empty URLs like this:

But as soon as the left part of the RewriteRule directive should be
empty, it automatically inserts the full path of the directory on the
web server, like here:

Whereas this works:      (notice the trailing slash)

Can anybody please explain me why it doesn't just redirect to the new
domain's root directory? Where does that serverside path come from? I
can't find any hint on it in the documentation.

This is really bugging me since it is one of the few issues I have with
a simple and reliable redirection of my website to one single domain name.

Yves Goergen "LonelyPixel" <>
Visit my web laboratory at

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