How to redirect traffic from one domain to another, just using four lines of code
Inside jokes are the best, and I got a kick out of being mentioned by the shape guy, I noticed something about the referrers. Normally, they would come from some derivative of theshapeofdays.com, with the 'the' in the domain name. Rarely, about 10% of the time, it would be from shapeofdays.com. I thought about this for a while, and came up with what I always do: steal from somebody who knows what they're doing.
If you know anything about webservers, you know the .htaccess file is a powerful thing. With that, you can redirect different servers to your homepage, or anywhere you want. A couple of lines of code and you can change all those bad people who refuse to change their links, and move into the 00s. Here's the ultra-simple four lines of code:
RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} ^www\.shapeofdays\.com$ RewriteRule (.*) http://theshapeofdays.com/$1 [R=Permanent]
This will move anybody from http://www.shapeofdays.com or http://shapeofdays.com to the desired domain. It's just a personal preference, but the 'www' in front of your domain name tends to be absolutely valueless these days. I try to take out as many of them as I can, but there's not hard, fast rule about this. The rewrite rule could point to wherever you want.
Now, knowing Jeff like I know 'im, he's got his own way of thinking, and does his own thing. Right now you can go to either domain, and all the links work correctly, with the 'the' in them all. Adding these lines could make the traffic work correctly. Yes, I said could.
With every sure thing, there's a dark side. While .htaccess is a wonderful thing, it's not my server, so I have no friggin' clue what's on there. And, while the redirects would work out for links, I'm not sure how images would fare for the hot-linkers in the house. I also don't know how the RSS feeds would work, since they follow the same mod_rewrite rules, but they tend to not play well with feed aggregators.
Then there's the /? problem. In many blogging platforms like WordPress and Movable Type (mine and Jeff's respectively), is how they handle the titles of posts. In WordPress, every page is rendered dynamically, so even the .htm files that look like they're strait HTML files really aren't. Part of that system, also in the .htaccess, is a convention that says anything following ? is regarded as a query to the php system. This makes redirecting anything that starts with ? a problem for me.
Is Movable Type like that; does it have the same problem? I dunno, but I'll venture the risk that any RSS feed will break with the redirect, and he'd have a page full of error pages in his "whimsical collection of stats that jack his...er...sanitation..." I have a Google Reader that hits me about every day or so, and there's probably something I could do about it, but I just haven't figured is out just yet.
Regardless, there's your four lines of code, and there's your redirect.
status: published
lastmod: '2006-10-01T07:15:29.000Z'
author: John Stansbury
cms: wordpress
custom:
podPressPostSpecific: 'a:6:{s:15:"itunes:subtitle";s:15:"##PostExcerpt##";s:14:"itunes:summary";s:15:"##PostExcerpt##";s:15:"itunes:keywords";s:17:"##WordPressCats##";s:13:"itunes:author";s:10:"##Global##";s:15:"itunes:explicit";s:7:"Default";s:12:"itunes:block";s:7:"Default";}'
_utw_tags_0: 'a:3:{i:0;O:8:"stdClass":1:{s:3:"tag";s:9:".htaccess";}i:1;O:8:"stdClass":1:{s:3:"tag";s:6:"coding";}i:2;O:8:"stdClass":1:{s:3:"tag";s:5:"howto";}}'
similarterms: domain lines shapeofdays work redirect http code thing problem htaccess links rule rewrite theshapeofdays change move files page system type
_utw_tags_: 'a:3:{i:0;O:8:"stdClass":1:{s:3:"tag";s:9:".htaccess";}i:1;O:8:"stdClass":1:{s:3:"tag";s:6:"coding";}i:2;O:8:"stdClass":1:{s:3:"tag";s:5:"howto";}}'
