home | list info | list archive | date index | thread index

[OCLUG-Tech] www or not www?

On 14 Apr 2006 at 8:52, Adrian Irving-Beer wrote:

> On Fri, Apr 14, 2006 at 03:36:07AM -0400, sberaud wrote:
> > I think,
> > 
> > At least I now have NamedVirtualHosts in Apache working correctly. I 
> > needed the server alias directive to be set for each new virtual domain 
> > - don't I feel silly.
> 
> Assuming you mean the ServerAlias directive... yeah, it's important that
> you cover every single name that users might use to contact your virtual
> host.  Typically that means "www.domain.com" and "domain.com".  Just
> using "domain.com" isn't enough to cover "www.domain.com".

Browse to langille.org.  You get redirected to www.langille.org.  
Why?  Because I want it that way.  I used to allow both.  Now I allow 
only the www.  I could just have a ServerAlias.  But I don't.  I do 
this:

<VirtualHost *>
     ServerAdmin dan [ at ] example [ dot ] org
     ServerName  langille.org

     Redirect        permanent / http://www.langille.org/

     ErrorLog        /usr/websites/log/langille.org-error.log
     CustomLog    /usr/websites/log/langille.org-access.log combined
</VirtualHost>

It allows the user to enter the short form and still get to where I 
want them.

If I allowed both, robots would be taking twice as bandwidth as 
necessary.  They'd be downloading both langille.org and 
www.langille.org.  It also means that web proxies/caches would be 
caching additional pages they don't need to cache.  This isn't an 
issue for langille.org, but it is an issue for freshports.org which 
has about 370,000 pages.

> To avoid the confusion of getting the wrong host, I set up my servers
> so that using the IP (or the hostname, e.g. "hostname.mydomain.com")
> gets you a "default" site (/var/www/default).  This is like the host's
> "personal" webspace, where we can put miscellaneous things for people
> to download, server status pages, etc.

Same here.  As an exercise, browse to http://www.langille.org/, then 
compare that with what you see when you browse to the IP address of 
www.langille.org.

> Accessing just plain "http://hostname.mydomain.com"; is an index of
> these things from inside my network, or a 403 "forbidden" error from
> outside.  This means it's abundantly clear if a domain is set up
> incorrectly -- I get a directory index rather than getting another
> "real" virtual site.

I set up the default website for the same reason.


message navigation