Yost.com – Apache redirect

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

* the redirect from www.nuevaschool.org to NuevaSchool.org

* the redirect from nuevaschool.org to NuevaSchool.org

viaYost.com – Apache redirect.