Apache redirect

to support multiple names for the same web site

(If you were looking for how to make html redirect files, look here.)

Transitioning from use of the "www." prefix on web site names...

Our example web site, Nueva School, set up Apache so that if you type in http://www.nuevaschool.org

your browser will replace that with http://NuevaSchool.org thus:

This redirection works even if you use a longer URL, such as http://www.nuevaschool.org/fcurric.html.

Not only was their web server able to get your browser to drop the unwanted "www." prefix, but it was able to get the browser to show the desired mix of upper and lower case letters. (There is no functional upper-lower case distinction in Internet domain names; it just makes it easer to read for us humans.)

Apache server version 1.3 or later is required for this to work. (If you know of how to do the same thing with different web server software, please let me know.)

Here are the lines from the Apache httpd.conf file that handle this redirection:

NameVirtualHost 209.233.38.3

<VirtualHost 209.233.38.3>
Servername NuevaSchool.org
</VirtualHost>

<VirtualHost 209.233.38.3>
Servername www.NuevaSchool.org
ServerAlias *
Redirect permanent / http://NuevaSchool.org/
</VirtualHost>

Be sure to include the trailing / at the end of the Redirect directive.

The Redirect directive is where you must put your desried mix of upper and lower case letters. The ServerName directives ignore case.

The line

ServerAlias *

above also takes care of redirecting all the other aliases for the site, such as

Nueva.pvt.k12.ca.us
www.Nueva.pvt.k12.ca.us

A handy web page, HTTP Header Viewer, allows you to see the HTTP protocol details of the above permanent redirect, as in

Apache documentation:

Virtual Hosts

Redirect

Why use redirection in addition to domain name aliasing?

We could just arrange for the DNS server to return the same IP address for both www.NuevaSchool.org and NuevaSchool.org, without the Apache virtual host redirect stuff, which is what we used to do.

One problem with that approach is that invariably there will be links to the web site under both names, and search engines will be led into indexing pages from the site under both addresses. This wastes search engine bandwidth and space, the web server's bandwidth, and the time of people sorting through duplicate search responses. Furthermore, many search engines decide on how strongly to hold onto your pages partly based on how many links there are into the site. So when links into your site are counted in different buckets, one for each of the variant host names, the number of inbound links in any one bucket might not be enough.

Thanks to Neal McBurnett for clarifying this for me.

Why care about upper and lower case in a domain name?

Domain names and email address names typically pack a lot into few letters. Before you can make sense of a string of all lower-case (or heaven forbid, all upper-case) letters, you first have to parse it because it could be

Unusual names cause the most difficulty because you often can't be sure if it really is an initial followed by a name
    crampling - is it Crampling or CRampling?
    price - is it Price or PRice?

Multiword phrases are easier to read if upper case letters are used as signposts in place of the omitted spaces
    paloaltochamberorchestra.org -> PaloAltoChamberOrchestra.org

Fortunately, in domain names and email address names, you can mix upper and lower case letters at will, and the computers will not care.

I say go for readability!

A doomed enhancement to Apache

If you're into this upper and lower case thing, you might think, "Wouldn’t it be nice if I could get the browser to always show the mix of upper and lower case letters I want, even if the user typed in the exact domain name but without the preferred mix? Unfortunately, because of a Windows Internet Explorer bug you must not try to do this, although you can do it for other browsers if you patch Apache.


http://Yost.com/computers/apache-redirect/ - this page
1999-10-17 Created
1999-11-12 Modified
2005-08-03 Added link to mkredir