You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by John Smith <jo...@yahoo.com> on 2003/11/28 20:58:39 UTC

[users@httpd] redirecting domain.com to www.domain.com

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)?

Thanks,
John

__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

---------------------------------------------------------------------
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


Re: [users@httpd] redirecting domain.com to www.domain.com

Posted by Robert Andersson <ro...@profundis.nu>.
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 Herb Stein <he...@herbstein.com>.
> -----Original Message-----
> From: John Smith [mailto:john_smith_45678@yahoo.com]
> Sent: Friday, November 28, 2003 1:59 PM
> To: users@httpd.apache.org
> Subject: [users@httpd] redirecting domain.com to www.domain.com
>
>
> 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)?

Assuming DNS points to the same IP address for both,
add ServerAlias to the virtual container.

> Thanks,
> John
>
> __________________________________
> Do you Yahoo!?
> Free Pop-Up Blocker - Get it now
> http://companion.yahoo.com/
>
> ---------------------------------------------------------------------
> 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
--
Herb Stein
The Herb Stein Group
www.herbstein.com
herb@herbstein.com
314 952-4601



---------------------------------------------------------------------
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