Redirects with .htaccess

I may have come up with a solution for the RSS errors I’ve been seeing.

When I combined Maria Langer, the Official Web Site* with my personal WebLog and LangerBooks.com, my book support site, into one site at www.aneclecticmind.com, I soon realized I had a problem. A bunch of people who were accessing the RSS feed for my old Mac OS X VQS book support site were still looking for it at the old address. Trouble is, it wasn’t there anymore. So these feed readers were looking for something they’d never find. And rather than give up and get on with their feed reader lives, they evidently kept looking, day after day, week after week. The people following the feed were probably either too overwhelmed by other content to notice my absence or had the silly idea that I just wasn’t writing anything new.

I discovered this, by the way, by checking the Users Online feature of my site. If I had a bunch of users online, I’d pop over to that page to see what they were looking at. I noticed that some of them were looking at my Oops! Page Not Found page. And when I pointed to the URL link, I saw that the page they were trying to get was the feed page for the Mac OS X books.

What could I do? I didn’t know. But the problem always bumbled around in the back of my mind. I figured I’d resolve it sooner or later.

Today, while waiting for a friend I’d taken to the doctor’s office, I killed some time listening to podcasts on my iPod. One of them was a podcast I’d only recently subscribed to: Podcasting Underground. In one episode, the host brought up a problem he’d experienced using redirects in his podcast feed. Although I didn’t have the same problem and his solution didn’t apply to me, it got me thinking. Redirects. Of course!

To those of you who don’t know, a redirect is an instruction that tells the visitor to Web content that the content isn’t available where he’s looking but is available elsewhere. It redirects him to the correct place.

There are at least two kinds of redirects — at least two kinds that I know about, that is.

One is extremely basic and uses an instruction in the head element of a Web page to send the visitor elsewhere, occasionally with a timer. Whenever you go to a Web page that says “We’ve moved to http://blahblah.com. Click this link if the new page does not appear automatically in five seconds.” That page has a redirect with a five second delay. It’s an easy redirect to create (if you have HTML knowledge) but it does waste time and effort by letting the visitor go to the wrong place in the first place. It also requires an HTML document at the wrong location. Not very smart, if you ask me, but it does have its purposes.

The other redirect requires rolling up the sleeves and editing the invisible .htaccess file that can live in a variety of places on a Web server, including the server’s root directory, a Web site’s root directory, or a specific directory within a Web site. This file can contain all kinds of instructions, as you can learn about in the Comprehensive Guide to .htacess or elsewhere online. (Just Google .htaccess and don’t forget the leading period or “dot.”)

The only instruction that interested me was the redirect command. It uses the format:

Redirect olddirectory/oldfile.html http://www.newsite.com/newdirectory/newfile.html

So I composed a command string that I think should work, stuck it in my .htaccess file, and resaved the file to my server. The new file location is set to the RSS feed for this entire blog. I figure they can always come back and change their subscription for the specific content they want.

Now it’s wait and see. I’ll keep peeking at the Users Online page to see if there are any people on the error page, then point to the URL to see what they were trying to find. If it’s the old RSS feed file, I’ll tweak my .htaccess entry accordingly. So far, I’ve only had to tweak it once…it looks like it might actually be working.

Oh, and by the way, if you’ve found this article through an RSS feed that you haven’t seen activity in for about six months, welcome back! You’re one of the readers I lost to this error. Visit the RSS Feeds page and subscribe to the content you want. I promise I won’t move the RSS feed addresses again without a redirect.

And if you know any other good online resources for .htaccess information, please use the comments link to share their URLs with readers.

.htaccess, howto, redirect, 404, RSS, feed

One thought on “Redirects with .htaccess

What do you think?