On Thu, Jun 2, 2011 at 5:13 PM, Geoff Millikan <gmillikan@xxxxxxxxxxxxx> wrote: >> Incorrect. The first vhost is ALWAYS used when no vhost with a >> matching host name is found - it is the catch all vhost, by >> definition. > > Yes, I totally agree. ÂBut, the first vhost cannot be used to *redirect requests to another vhost.* ÂPer Eric Covener, "You can't > make the catch-all vhost also be a reachable name-based vhost, with those rewrite rules. ÂCreate an additional one solely for that > purpose." > > If you're wanting to redirect all hostnames to parent domain name then the first vhost cannot be used for this purpose unless > there's another solution the list hasn't thought of yet? > You misunderstood what Eric said. The first vhost absolutely can be used to redirect requests to another vhost. This is the canonical way to setup Apache to deal with misconfigured vhosts and redirect them to a preferred vhost. Eg, I have a server with a wildcard DNS enabled for *.foo.com. Most of the resolvable DNS names aren't valid, and so should be redirected to the www.foo.com vhost: <VirtualHost *:80> ServerName localhost DocumentRoot /var/empty RewriteEngine On RewriteRule ^.* http://www.foo.com/ [L,R=302] </VirtualHost> <VirtualHost *:80> ServerName www.foo.com DocumentRoot /var/www/www.foo.com/htdocs </VirtualHost> <VirtualHost *:80> ServerName code.foo.com DocumentRoot /var/www/code.foo.com/htdocs </VirtualHost> Requests for http://not-valid.foo.com/whatever/ do not match a vhost, and so are routed to the default vhost, which redirects them to http://www.foo.com/ If you want to ALSO redirect from a specific hostname to another specific vhost, then you must add another vhost for that specific purpose, as Eric mentioned. If I had a site 'www-beta.foo.com', which should now show 'www.foo.com', I would need to add an additional vhost like so: <VirtualHost *:80> ServerName www-beta.foo.com DocumentRoot /var/empty RewriteEngine On RewriteRule ^/(.*) http://www.foo.com/$1 [L,R=302] </VirtualHost> I don't think I can make it any clearer than that - hope that helps. Cheers Tom --------------------------------------------------------------------- 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: users-unsubscribe@xxxxxxxxxxxxxxxx " from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx