Apache rewrite: multiple domains --> singledomain/directory

Apache rewrite: multiple domains --> singledomain/directory

Post by QB » Thu, 16 May 2002 08:46:03



this is extraordinarily confusing for me, and I would appreciate any
help! I'm lost!

I've got a set of about 20 domains like this:

www.fooBAR.com
www.fooBAZ.com
www.fooBOO.com

I would like users coming to these urls to be redirected to the following:

www.realdomain.com/BAR
www.realdomain.com/BAZ
www.realdomain.com/BOO

I've tried so many things, I can't even imagine what I'm doing wrong.

The last thing I tried was something along the lines of:

<VirtualHost ......>

(the usual here)

RewriteCond %{HTTP_HOST} ^www\.foo([a-z]+)\.com [NC]
RewriteRule ^www\.foo([a-z]+)\.com/(.*)
http://www.realdomain.com/$1/$2 [L,R]

</VirtualHost>

This is on a system with many virtual hosts, if that point matters.
What's the best way to do this? Any help is greatly appreciated!

 
 
 

Apache rewrite: multiple domains --> singledomain/directory

Post by Joshua Sliv » Thu, 16 May 2002 09:38:37


Rewri*gine On

Quote:> RewriteCond %{HTTP_HOST} ^www\.foo([a-z]+)\.com [NC]

RewriteRule (.*) http://www.veryComputer.com/%1/$1 [L,R]

Your problems where:

1. You need to use the rewritelog to figure out what is happening.

2. RewriteRule matches only against the URL-path, not the full
URL.

--
Joshua Slive

Apache HTTP Server Users Mailing List: http://www.veryComputer.com/

 
 
 

Apache rewrite: multiple domains --> singledomain/directory

Post by QB » Thu, 16 May 2002 10:19:13


Quote:> RewriteRule (.*) http://www.realdomain.com/%1/$1 [L,R]

> Your problems where:

> 1. You need to use the rewritelog to figure out what is happening.

i actually did that, but still can't understand whats going wrong. its a
little vague (to me anyways)

Quote:> 2. RewriteRule matches only against the URL-path, not the full
> URL.

so what would i have to do to get the effect i described?

& thank you

 
 
 

Apache rewrite: multiple domains --> singledomain/directory

Post by Joshua Sliv » Thu, 16 May 2002 12:18:29



>> RewriteRule (.*) http://www.realdomain.com/%1/$1 [L,R]

>> Your problems where:

>> 1. You need to use the rewritelog to figure out what is happening.
> i actually did that, but still can't understand whats going wrong. its a
> little vague (to me anyways)

Then you should quote it with your post to help the rest of us.

Quote:>> 2. RewriteRule matches only against the URL-path, not the full
>> URL.
> so what would i have to do to get the effect i described?

The example I quote above should come close.  Notice the "%1" is a
"back-reference" to the matched pattern in the RewriteCond.  See also
the Rewrite Guide in the apache docs which has an example of mass-virtual
hosting using mod_rewrite.

--
Joshua Slive

Apache HTTP Server Users Mailing List: http://httpd.apache.org/userslist.html