You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Robert Andersson <ro...@profundis.nu> on 2003/12/01 07:20:40 UTC
Re: [users@httpd] redirecting domain.com to www.domain.com
John Smith wrote:
> What's the easiest (and/or best) way to go about
> redirecting all requests for domain.com to
> www.domain.com? The only way I can think of is to set
> up separate VirtualHost's for each, and put a
> "Redirect xxx / http://www.domain.com" in the one for
> domain.com. Anything easier (I have quite a few
> virtualhosts)?
Depending on your requirements, you could do this by defining a single dummy
virtual host as the first one, which then redirects. Eg:
<VirtualHost *>
ServerName dummy
Redirect / http://www.domain.com/
</VirtualHost>
<VirtualHost *>
ServerName www.domain.com
...
</VirtualHost>
...
All requests that cannot be matched to a more specific VH, will go to the
first one as default, and there get redirected to the www.domain.com VH.
However, it will not be possible control which hosts this redirect is
performed for, and you can only have one catch-all VH in an Apache
installation so you cannot use that feature for something else.
Regards,
Robert Andersson
---------------------------------------------------------------------
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@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] redirecting domain.com to www.domain.com
Posted by Jim Walls <k6...@earthlink.net>.
Robert Andersson wrote:
>John Smith wrote:
>
>
>>What's the easiest (and/or best) way to go about
>>redirecting all requests for domain.com to
>>www.domain.com? The only way I can think of is to set
>>up separate VirtualHost's for each, and put a
>>"Redirect xxx / http://www.domain.com" in the one for
>>domain.com. Anything easier (I have quite a few
>>virtualhosts)?
>>
>>
Server alias takes care of that (at least in virtual hosts). Here is
one of the virtual hosts directive in my httpd.conf file:
<VirtualHost *>
ServerName www.k6ccc.org
ServerAlias k6ccc.org *.k6ccc.org
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/k6ccc.org"
</VirtualHost>
The server is actually named www.k6ccc.org (defined in the second line),
but the third line specifies that k6ccc.org or anything.k6ccc.org will
work as an alias. To verify that this worked, I typed the following
into my browser: http://fnamfa.k6ccc.org/ and got my web site.
-------------------------------------
Jim Walls - K6CCC
k6ccc@amsat.org
Ofc: 626-302-8515
http://home.earthlink.net/~k6ccc
AMSAT Member 32537 - WSWSS Member 395
---------------------------------------------------------------------
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@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org