Hello,

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 .+ desired_hostname=beta.unclassified.de
    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
unclassified.de, which is also the document root of beta.unclassified.de.

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:

    http://unclassified.de/beta/kontakt
    -> http://beta.unclassified.de/kontakt

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:

    http://unclassified.de/beta
    -> http://beta.unclassified.de//www/web002/beta

Whereas this works:

    http://unclassified.de/beta/      (notice the trailing slash)
    -> http://beta.unclassified.de/

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" <[EMAIL PROTECTED]>
Visit my web laboratory at http://beta.unclassified.de

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: [EMAIL PROTECTED]
   "   from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to