The Definitive Guide to Apache mod_rewrite

Hardcore .htaccess stuff for mere mortals like me.

Somewhere along the line recently, I got this idea in my head that I wanted all subscribers for my main feed here to get the FeedBurner version of the feed. Those of you who are familiar with RSS know that a feed icon appears in the address bar of most modern Web browsers, offering visitors a quick way to get the feed URL or create a live bookmark. Other folks might know that they can enter the URL for a WordPress-based site followed by the word feed to get a feed URL. There are a few other formulas that can be used to generate a workable feed URL for subscribing to a feed, too.

While that’s all well and good, with so many methods to subscribe to feed content, it’s nearly impossible to get a real count of subscribers. How many people are subscribed to my feed? Beats me. How many hits a day does it get? I don’t know.

And those of you who have been reading this blog for a while know how much I love stats.

So a did a little poking around on the Web and found a few articles that explained how to use .htaccess to redirect hits to WordPress-generated feeds to my FeedBurner feed. One was this thread on the FeedBurner site, which has special instructions for WordPress users (scroll down on that page). Another was this article on oneafrikan.com, which offered some additional tricks I found useful.

Unfortunately, these solutions had one thing in common: they redirected all feed links to a single FeedBurner feed link. While that’s fine for most people, I’ve just gone through a lot of trouble to set up and promoted category feeds on my site. The last thing in the world I wanted was for someone to subscribe to a category feed and then get the main feed in their feed reader.

Of course, all of this redirect magic is done with .htaccess, the “invisible” file that works with your Web server to provide some last-minute instructions for your site. I’d already played a bit with .htaccess settings to make sure that outdated URLs published in some of my older books still pointed to the right thing on my current site. And, of course, WordPress uses the .htaccess mod_rewrite module to change ugly PHP URLs into something more attractive and logical (although very lengthy, if you ask me). I knew only enough about .htaccess to be dangerous with it, but since I treat it like a vial of nitroglycerin, I haven’t gotten myself in trouble yet.

So I figured I’d take the oneafrikan.com settings and modify them to meet my needs. The trouble is, when I looked at the code, I couldn’t translate them into a language I understood (such as English), so I couldn’t modify them to meet my needs or anyone else’s.

I spent some more time on the Web and found lots of documentation. Unfortunately, all of it assumed I knew the basics of what I now know are called regular expressions: those punctuation marks that mean something completely different from the punctuation I’m used to as a writer. Not knowing what they were called made it impossible for me to look them up online. When I started looking at the same apache.org page over and over and it never changed (not that it should, mind you), I realized I needed more advanced (or perhaps basic) help.

What I needed was a book.

I don’t just write books. I read them, too. Although I very seldom read a computer book cover to cover, I have a bunch of them that I consult when I need to figure something out. Oddly enough, some of them are books I’ve written; I tend to forget things I’ve written about when I don’t use them regularly. (And they call me an expert! Ha!) I have a book by another author that covers Apache, but the information I needed was not in there. In fact, I’m trying to figure out why I bought that particular book in the first place.

The Definitive Guide to Apache mod_rewriteSo I went on Amazon.com and I searched for .htaccess. I came up with a list of books that referenced it, but were not about it. Then I searched for mod_rewrite. And voila! I found The Definitive Guide to Apache mod_rewrite by Rich Bowen.

Not anxious to plunk down $30 for a book I might not find my answers in, I did some more research on the Web. I found a few book reviews and they were all positive. It appeared that this 160-page book covered the topic quite completely. It was definitely the book I wanted on my shelf.

Of course, I didn’t feel like waiting for Amazon.com to ship it to me. (I like immediate gratification almost as much as stats.) So when I realized that the publisher’s Web site offered the book as an eBook for only $20 (half the cover price), I bought it online and downloaded it. In five minutes, I had the answer to my question and enough information to tackle the problem. But rather than read the book on my 12″ PowerBook’s tiny (well, 12 inches, right?) screen (my G5 is still feeling sickly), I printed the whole thing out, punched holes in the pages, and put it in an old binder I had sitting around.

I realize that once again I’ve turned a short story — I found a great book about using mod_rewrite — into a long and drawn out one. (There are no short stories here.) My apologies to those of you in a hurry.

The point I wanted to make is that The Definitive Guide to Apache mod_rewrite is an extremely well organized, reader-friendly, well written, and informative book that explains exactly how to use mod_rewrite for anything you might want mod_rewrite to do: rewrite URLs, control access, set up virtual hosts, and so much more. Plenty of examples, each of which is analyzed and discussed. It’s all there.

I’m only about 30 pages into it so far, but I’m already very pleased.

Long Lost Cousin Found

A true story involving an odd last name, the Daytona 500, Google, and one of my Web sites.

The other day, I got an e-mail message from a guy named Steven P. Obviously, his name was not just P. It began with a P and was somewhat unusual. Pretend, for simplicity and to keep this guy’s identity private, that it was just plain P.

Here’s what he wrote.

My name is Steven P. I was getting tickets for the Daytona 500 and was surprised to find another P in the Ticket registery. All I got was Mike P from Pheonix. I googled his name and got a website with your writings. I also got a guest book for Benny Parson’s that Mike had left a message at. I was just wondering if you know Mike? I have lived in Tampa Florida all my life. I have family in Bradenton. All of them have passed, just cousins left. I was just trying to find out if we are family. If you know him and could tell him about this message I would be thankful. My EMail is scp@yahoo.com [not his real address].
Thanks, Steven

I don’t know who or what Benny Parson’s is, but I did track down a comment written by Mike P on my wickenburg-az.com Web site.

I don’t know Mike P. He’s not listed in the Wickenburg phone book. And I wrote back to Steven P to tell him that. But, at the same time, I told Steven P that I’d send Mike P a copy of his message. Since WordPress requires commenters to enter an e-mail address, I had one for Mike P. (Oddly enough, it was also a yahoo.com address.) So I forwarded Steven P’s message to Mike P with an apology for bothering him just in case they weren’t related.

A few days later, I got the following message from Steven P:

Thank you so much for forwarding my Email to Mike P. He Emailed me back and we are family. His Dad is my cousin who lives in Florida. We don’t see each other and I never knew he had kids. Thanks again. Steven

Now doesn’t that make you feel all warm and cuddly inside?

Backup at the Touch of a Button?

We’ll see.

The first thing I did when my hard disk failed on Friday (for the fourth time in less than 10 years) was to go online and find an external hard disk that had enough capacity to back up my computer’s entire hard disk. And while I was at it, I’d get one that was bigger than my current hard disk so I could use it for my next computer (which will probably be purchased sometime before the end of this year).

Seagate ST3300601CB-RK 300 GB External Hard Drive with FireWire and USB 2.0 InterfaceI started at the Apple store, figuring that the products sold there would work effortlessly with my Mac. I found a Seagate 300 GB model (the Seagate ST3300601CB-RK) that boasted “pushbutton backup.” Now that sounded like the right thing for me. I did a little Web searching and found the same hard disk on Amazon.com for $40 less. I ordered it. It should arrive sometime next week — hopefully right around the same time TechTool Pro finishes doing whatever it can to recover my data.

SmartDisk FWFL80 80GB Firelite 2.5In the meantime, I still have two 80GB Smart Disk FireLite portable Firewire hard disks to capture whatever can be scavenged from the disk.

I’d like to hear from readers about backup strategies and solutions, as well as any experiences with Seagate’s “award-winning Bounceback Express software.” (I’m extemely skeptical about this solution.) Use the Comments link. And if you want to share a hard disk crash story with us, please do. I can’t be the only one out there losing hard disks.

Computer Woes

Again.

If you were starting to wonder whether I’d fallen off the face of the earth, stop wondering. I’m still here. It’s my main computer’s hard disk that has decided to take an extended leave of absence from work.

It happened on Friday. It was doing four things at once as it usually does and it completely locked up. I had to power it down to unlock it. When I powered it back up, I had a blinking System folder icon. Never a good sign on a Mac.

Long story short: TechTools Pro has been working on the disk for about 37 hours now, trying to recover what was on the disk. It’s not even halfway finished, so I figure it’ll be done by Tuesday or Wednesday. Until it’s done, the computer is pretty much dead in the water. And maybe even after it’s done.

This has happened to me before, so most of my stuff is backed up. But a few things aren’t. Like 4 hours worth of work on Chapter 6 of my Excel 2007 Visual QuickStart Guide. What annoys me most about that is that it was the second time I went to work on that Chapter. The first time, I didn’t like the way it was coming out so I scrapped it.

If the data can’t be recovered by me or by experts elsewhere, I’ll have to rebuild the hard disk’s contents from scratch on a new hard disk. I’ll know if I need to do that sometime near the end of the week.

In the meantime, I have three laptops to work with: My trusty 12-inch PowerBook G4 (which I’m writing on right now), my new MacBook Pro (which is resting until it needs to do duty as a test mule for my upcoming Leopard book), and my Dell laptop (which is what I was running Excel 2007 on while revising my Excel book). So I can keep blogging, keep writing short articles, and write my outline for my Leopard book.

I’m just a bit depressed about the work that faces me and the possibly hundreds of photographs stored only on that computer’s hard disk. I couldn’t back up everything. But that’s going to change very soon.

Full Text vs. Summary Feeds

What the hoopla is all about.

It’s a hot topic among bloggers. Full feeds or Summary feeds? I’ve exchanged some words with a reader here about it, but I’ve always been sitting on the fence.

RSS Feed Basics

For those of you who don’t have a clue what I’m talking about, let me take a moment to cover the basics.

This blog (and its individual categories or topics) is available in two formats: HTML viewable in a Web browser and RSS viewable in a feed reader (or aggregator). The HTML format includes nicely designed pages (if I do say so myself), access to polls and comments, and full site navigation features. The RSS format includes just the most recent posts in whatever format a subscriber’s feed reader displays them in.

The benefit of the RSS format is that content is automatically delivered to subscribers as it is published. There’s no need to visit the site to see what’s new. The feed reader will automatically gather all new content for reading at the subscriber’s leisure. You can learn more about RSS on Feedburner’s Feed 101 page.

Full-Text vs. Summary Feeds

Bloggers normally have the option of creating feeds as full text feeds or as summary feeds. (To set this option in WordPress, go to Dashboard > Options > Reading. We provide full instructions in our WordPress book.) A full text feed publishes the entire content of each post to the feed, making it unnecessary for the subscriber to come to the source Web site. A summary feed publishes just the beginning of each post to the feed, making it necessary for the subscriber to come to the Web site for the remaining content of each post he wants to read. (In WordPress, this is only the first 55 words.)

It’s pretty well established that full text feeds attract more subscribers than summary feeds, so if getting more subscribers is a blogger’s goal, full text is definitely the way to go. But full text feeds have several drawbacks that have kept me from jumping on board:

  • Full text feeds eliminate the need for subscribers to visit the site at all. All your hard work on blog design is completely wasted on feed subscribers.
  • Because full text feed subscribers are less likely to visit your site, they’re also less likely to comment on entries. This reduces the interactive aspect of your site. I think this is a serious problem, since RSS subscribers are more likely to have something constructive to say about technical topics, which is what I often write about here.
  • Because full text feed subscribers are less likely to visit your site, they’re also less likely to click ads there, thus potentially reducing your revenue stream. (Of course, it’s a valid argument that RSS subscribers are more tech savvy and less likely to click ads in the first place.)
  • The appearance of feeds in a subscriber’s feed reader is dependent on settings within that reader. As a result, entry formatting can be lost, resulting in ineffective appearance to the reader. For example, headings may show up as boxes in the margins rather than as headings.
  • Full text feeds are more likely to be scraped by splogs. That means your content may be used by “bloggers” to build content on their advertising-heavy sites, as well as link farms and other unsavory Web traffic-generating or revenue-generating schemes.
  • If you write very long entries or include many posts in your feeds, you could reach feed length limitations with FeedBurner (if you use it).

For summary feeds, the only drawback is that they’re less likely to get subscribers since a lot of folks don’t think it’s worth subscribing to a feed if the entire content does not appear in their feed reader.

Sitting on the Fence

With all of this in mind, I’ve been using summary feeds since I switched to WordPress about a year ago. I haven’t been very interested in building the number of subscribers. This drew a lot of flack from a subscriber, especially when I couldn’t make up my mind and switched back and forth between the two kinds of feeds over the period of a number of weeks. I assume that she dropped her subscription when I stuck with summary feeds.

Now I’m more interested in building my subscriber base. So I’ve switched back to full text feeds. It’s been about a week, and my feed has already been scraped once, with a pingback that I assume was supposed to help the scraper’s Google placing. (I deleted that pingback comment as soon as I found it.) One subscriber (Miraz) has already joyfully commented on the switch. Others haven’t commented. I don’t expect them to, since there’s no way to comment from within the feed reader software (see drawback list above).

Anyway, I’m encouraging subscribers now and it’s a full text feed, so I invite you to subscribe. But please do stop by once in a while to share your comments with other site visitors.

March 6, 2011 Update: After a long run with full-text feeds, I finally switched back to summary feeds. I just got tired of seeing my copyrighted work automatically re-blogged on sites created by feed scrapers.