Welcome to Custom 404 Error Page! This site offers you information on how to create your own 404 error pages, some cool content you can add, and even how you can add links to other sites that aren't what they appear.

301 permanent redirects, 302 redirects in Apache

Working with 301 and 302 Redirects

Here's a problem you may have that is worth solving in the proper manner: how do you properly handle more than one domain name pointing to the same Web site? The lazy way is to set them up as server aliases, which can work pretty well. It looks like this:

ServerName www.birth.net
ServerAdmin
ServerAlias baby.net www.baby.net mothering.net www.mothering.net
ServerAlias apfamilies.org www.apfamilies.org
DocumentRoot /usr/local/etc/httpd/htdocs/birth/
ErrorLog logs/AP/error_log
TransferLog logs/AP/access_log
What these additional ServerAlias lines mean is that anything that comes in for one of the aliased domain names (baby.net, mothering.net, and apfamilies.org) is automatically mapped to the root domain, in this case birth.net. But this means that if there's a page called, say, "index.shtml", and someone clicks on the link http://www.mothering.net/index.shtml they'll be delivered the page that's at birth.net/index.shtml but the URL they'll see will be mothering.net, not birth.net.

So that works if you want to seem like you have a number of identical sites under different domain names, but what if you want to actually teach people over time that there's an "official" domain name? That's what the 301 and 302 error codes are for: redirection.

The difference between a 301 and a 302 redirect

A 301 and an 302 redirect are more or less identical, except a 302 is intended to be used as a temporary redirect, perhaps one that's used while a a site is under construction or a server is being moved. A 301 is a permanent redirect, on the other hand, so that's what we're talking about in this situation.

Adding a 301 or 302 redirect to Apache

To add a redirect to Apache is a breeze. In this instance, I want all traffic coming to www.debtfree-help.com to rewrite itself as traffic to the real domain name, www.real-life-debt.com:

Redirect / http://www.real-life-debt.com/
CustomLog logs/redir "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""

The "logs/redir" allows you to track just how much the redirect is getting used, and by whom. Every so often, check it out and you'll see who still has your old domain name in play.

Note that the above is a temporary (302) redirect. To switch it to a permanent (301) redirect, just change the Redirect line above to this:

Redirect permanent / http://www.real-life-debt.com/
or, if you prefer numeric codes:
Redirect 301 / http://www.real-life-debt.com/
You can learn more about 301 and 302 redirects at apache.org and you can visit real life debt.com by visiting debt free help.com. Watch the URL that's displayed in your browser if you do...

Many thanks to Steve Loyola of Best Web Buys.com for his assistance in preparing this article.