any apache guru's in the house?

any apache guru's in the house?

Author
Discussion

fatsteve

Original Poster:

1,143 posts

278 months

Wednesday 9th March 2005
quotequote all
I'm reaching the limits of my mod_rewrite knowledge.

Put simply, I need to configure apache so that I can point a number of domains at a single IP and then for apache to redirect to different URL's depending on the requesting domain name. RewriteMap and Rewritecond sound like the kiddies..

Example

www.abc.com redirect to www.wibble.com/c
www.def.com redirect to www.foo.com/b
www.ghi.com redirect to www.bar.com/a

I've been pulling my hair out over this. There are other ways (PHP), but I'd like to keep this purely in the apache domain rather than fiddling with scripts etc.

TIA

Steve

wildeep

362 posts

250 months

Wednesday 9th March 2005
quotequote all
You need to modify httpd.conf to use the virtual host directive e.g.

<VirtualHost www.somewebsite.com>
DocumentRoot /usr/local/etc/httpd/vhosts/somewebsite/
ServerName www.somewebsite.com
</VirtualHost>

the_bovine

65 posts

243 months

Wednesday 9th March 2005
quotequote all
Hi Steve - still with that electricity company?

Following on from the last post, create the VHosts; the magic line you want in each Vhost is -

(for example in the www.abc.com VHost)

Redirect permanant / www.wibble.com/c

That should do the trick . You could use mod_rewrite, but this is a simple redirect, so no need.

-- A refugee from Star Internet

fatsteve

Original Poster:

1,143 posts

278 months

Thursday 10th March 2005
quotequote all
wildeep said:
You need to modify httpd.conf to use the virtual host directive e.g.

<VirtualHost www.somewebsite.com>
DocumentRoot /usr/local/etc/httpd/vhosts/somewebsite/
ServerName www.somewebsite.com
</VirtualHost>


Thanks, avoiding using virtualhosts (esp name based) since I'd have to configure around 200+ (well I could automate it.

Steve

fatsteve

Original Poster:

1,143 posts

278 months

Thursday 10th March 2005
quotequote all
To answer my own question, here's what I've done and it works a treat:

RewriteEngine on
RewriteMap redirector txt:/path/to/redirector.map
RewriteRule /*$ ${redirector:%{HTTP_HOST}} [R]

The the redirector.map simply contains

www.site1.com www.site1sreplacement.com/a_page.htm
www.site2.com www.site2sreplacement.com/another_page.htm
www.site3.com www.site3sreplacement.com/yet_another_page.htm


Steve

obiwonkeyblokey

5,399 posts

241 months

Friday 11th March 2005
quotequote all
any of you apache gurus fancy a QA role near reading?

cheeky I know - sorry Ted.