[H-GEN] Multiple Domains - Apache
Nikolai Lusan
nikolai at lusan.id.au
Mon Apr 28 21:40:32 EDT 2008
Hey,
On Tue, 2008-04-29 at 10:02 +1000, Matthew Brecknell wrote:
> Not sure, but I think your problem may be due to virtual host
> "defaulting" for server names which apache does not know about.
That is how it works.
> I
> usually add a "dummy" server before any of my actual virtual hosts to
> help me discover bad virtual host configs.
>
> Anyway, here's how I do the www redirection:
>
> <VirtualHost *>
> ServerName a.example.com
> Redirect permanent / http://www.a.example.com/
> </VirtualHost>
>
> <VirtualHost *>
> ServerName www.a.example.com
> DocumentRoot /var/www/vhost/a.example.com
> </VirtualHost>
>
> <VirtualHost *>
> ServerName b.example.com
> Redirect permanent / http://www.b.example.com/
> </VirtualHost>
>
> <VirtualHost *>
> ServerName www.b.example.com
> DocumentRoot /var/www/vhost/b.example.com
> </VirtualHost>
This will only work if the request comes into a known hostname, it also
becomes harder to administer a large number of hostnames and would not
be the recommended way of doing things.
> This has the added advantage that the redirect is performed in the
> browser, not the server. This increases the value of any caching which
> is performed outside the server.
FYI the Redirect directive works in exactly the same way as the rewrite
rules we have been using, only rewrite is more powerful and flexible in
what it can do (e.g. a request coming into http://blah.foo.com/bar can
be sent to http://www.foo.com/bar without the admin needing to know what
bar is).
--
Nikolai Lusan
###################################################################
#
# Weblog: http://lusan.id.au/~nikolai/blog
# Webcam: http://lusan.id.au/~nikolai/webcam.html
#
###################################################################
More information about the General
mailing list