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:
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 redirectA 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 ApacheTo 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: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.
|