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.

Six Improvements For Your Blog

From lifehack.org

Interested in a few basic blog improvements? Chris Brogan’s article should give you some ideas.

From Six Improvements to Your Blog on lifehack.org:

I’ve done a lot of blog surfing lately, in search of new (best) blogs. What I found often, however, was that there are things people could do to improve the relationship and interaction value of their blogs, which would in turn build a better bridge between blogs and their readers.

Chris’s six tips are extremely basic, with advice that includes formatting posts to make them more legible and making it easy for readers to contact you. I don’t agree with everything said — for example, the contact advice doesn’t work for me and I don’t see anything wrong with captchas if they prevent comment spam — but it’s a good look at some things you may be able to do to improve your blog overall.

Does anyone have any other tips they might want to share with readers? Use the Comments link here.

Flying M Air Videos on YouTube

I take the videos mainstream.

Well, with YouTube pulling copyrighted video content from Comedy Central off its site every day, I thought I’d help fill the gap by adding Flying M Air‘s video podcasts to the YouTube servers. [Insert smiley here for the benefit of people who believe that I think my little videos can replace Comedy Central content.]

You can find all of the videos on the Flying M Air Channel.

Summer & Winter

At the same time.

Miraz Jordan, in her TiKouka blog, discussed my recent complaints about the oppressive heat here in Wickenburg. Miraz is in New Zealand. So while I’m dealing with heat, she’s dealing with the cold.

Her blog shows an image of the temperatures in Wickenburg and Wellington at the same time using Mac OS X’s Weather widget: 105° and 7° respectively. Holy Cow! I thought to myself. Is it really that cold there?

It isn’t. Miraz fooled me by showing Wickenburg’s temp in farenheit and Wellington’s in celsius. Here’s the current picture. A few notes: it’s early tomorrow morning in Wellington right now and it really isn’t raining in Wickenburg — although most of us wish it was.

Temperatures

Summer Plans

Maria Speaks Episode 26: Summer Plans.

A discussion of Howard Mesa and flying for hire, including cherry drying in Washington state.

Transcript:

Hi, I’m Maria Langer. Welcome to Episode 26 of Maria Speaks: Summer Plans.

Summer is here in Wickenburg and thermometer readings prove it. For the past three days, the thermometer on my back patio, which is positioned in the shade, has reached 110 degrees farenheit or more. While the metric equivalent of 42 or so sounds cooler, I don’t think it would feel any cooler. It’s downright hot here.

Wickenburg lies in the northern part of the Sonoran desert. That’s the desert with the big saguaro cacti and other low-water vegetation. We’re at about 2400 feet elevation here, which is at least a thousand feet higher than Phoenix, so we’re cooler than Phoenix. Well, cooler in temperature, anyway. You might be able to imagine how hot Phoenix is. Or you can just check the Weather Channel’s Web site for the shocking details.

For the past two summers, I’ve bailed out of Wickenburg for the summer months. In 2004, I got a job as a pilot at the Grand Canyon, flying helicopter tours on a seven on/seven off schedule. I lived in a trailer at our property on Howard Mesa during my on days. Howard Mesa is a 40-minute drive from Grand Canyon Airport at Tusayan. I was five miles from pavement, in the middle of nowhere, surrounded by peace and quiet and not much else. Unfortunately, I had a 13-hour work day, including commuting time. Near the end of the season, in September, I was leaving for work before sunrise and returning after sunset. Didn’t get much of a chance to enjoy the place.

Last year, in 2005, I spent the entire month of July at Howard Mesa with Alex the Bird, Jack the Dog, and our two horses. The property is fenced in, so the horses just wander around. I was living in the trailer again, but working on a project. We’d installed a 12 x 24 foot shed there and needed to get things inside it organized. In the future, we’ll use it to store materials for when we build a house up there. Now, it stores other stuff.

Don’t get the idea that our place at Howard Mesa is some kind of luxury accommodation. It isn’t. It’s off the grid, so we don’t have electricity. The trailer has a solar panel on the roof that tends to keep the battery charged. There’s a thousand-watt generator up there just in case the batteries die down. There’s no television, telephone, microwave, or dishwasher. Water comes from two tanks that hold a total of about 2100 gallons; when water levels get low, we pay someone to fill them back up. We did install a septic system, so there are no worries when it comes to using a toilet. Thank heaven.

The shed now has solar panels and will soon be wired for lighting. There’s a fridge and stove in there and a big propane tank out back that keeps them running. There’s other camping gear there, as well. It’s very basic, covering the bare necessities. That’s fine with me. Sometimes it’s good to get down to basics, just so you realize how luxurious your regular home — no matter how small or sparsely furnished — really is.

This year I was trying to get completely out of Arizona for the summer. I applied for two different jobs in Alaska and was told I could have either one — if I started in April. I couldn’t start that early. I was working on a Visual QuickStart Guide for Peachpit Press and those require that I spend long hours in front of a computer with a big screen, laying out every page of the book manually. Although I originally expected to be finished by early May, some medical problems slowed me down. I’m okay now, but the book is just being finished. It’s early June, so the way I see it, I lost a whole month.

I also got called about a job drying cherry trees in Washington State. I wrote about it in my blog. Here’s how it works. The cherry trees start getting fruit in June. It also rains in June. The raindrops settle on the fruit. If the fruit isn’t dried, it splits. No one wants to buy split cherries, so the farmer loses his crop. Evidently, a number of people sell what they call insurance to the farmers. If the farmers buy in, when it rains, a helicopter magically appears over their fields to dry the cherries. The helicopter does this with downwash from its main rotor blades. It hovers about 4 feet over the tree tops and moves along the rows at about 4 miles an hour. A helicopter like mine can dry 40 acres of cherry trees in an hour.

The work is dangerous, primarily because of the wires that are all over and around the fields. Every year, a couple of pilots get their tail rotors tangled up in wires and wind up down in the trees, wrapped up in a mangled helicopter. But I’m always willing to try something different. The way I see it, I did okay at the Grand Canyon and I did fine racing with boats at Lake Havasu earlier this year. I’m a careful pilot and should be able to do a decent job in the cherry orchards.

Of course, there are only a certain number of spots open to pilots and aircraft. I had three things going against me: First, I’d never done it before, so I was an unknown. Second, I didn’t have a fuel truck driver to deliver fuel to me out in the fields. (One of the guys offered to let me share his truck, though, so that wasn’t a big hurdle.) Third, I was based in Arizona and would have to make an 8-hour flight to Washington State just to settle into my base there. The folks who do the hiring didn’t want to pay for that 16-hour round trip ferry flight and I couldn’t blame them. But I had to charge a bit more than some of the local pilots to cover my travel costs and the outrageous cost of special insurance I’d have to get just for the job.

So they never said yes. But they never said no. When questioned, they kept saying maybe. Time passed. The season start day approached. I assumed they weren’t interested — they never said yes. One of my contacts — the guy who brought me into the running — got an assignment that started on June 5. That’s yesterday. He put me in touch with someone else. That guy told me I had an 85% chance of getting work if I came up there. I read between the lines. He was suggesting that I fly up there and just settle into a hotel and wait. Without a contract.

Now let me explain how payment for this kind of job works. Pilots get a contract that’s usually for about 30 days. The contract includes a per diem amount for standby time. That amount covers the cost of your hotel room, food, ground transporation, and, in my case, insurance (at a whopping $150 a day). The contract also includes a per hour fee for actual flight time. So the more you fly, the more you make, but if you don’t fly, at least you have your basic costs covered.

This guy was suggesting — without actually suggesting it — that I fly up there and go on standby without per diem compensation. So not only would I have to eat the ferry cost, but I’d have to eat my hotel cost, too. Unless I flew. I was told that I could charge more per hour if I didn’t have a contract, but I’d obviously be the last pilot called if I was also the most expensive.

When I pretended, in our phone conversation, not to pick up on this, he went on to tell me that they might still need me. They’d know for sure by Monday (yesterday) and would call then. They’d need me to be there by the end of the week.

This kind of bugged me. I was finishing up my Visual QuickStart Guide and needed the rest of the week to get it done right. These guys expected me to drop everything, hop in my helicopter, and fly up. When they called. If they called.

Well, I didn’t get a phone call from cherry-land yesterday.

Now I do need to admit that this whole wait-and-see situation was starting to get on my nerves. It was okay back in April when I was first introduced. With enough notice, I could shape my summer around the job. True, I did have a book to work on in June, but I figured that I could work on it in my hotel during my standby time. I’d just have to get a PC laptop — which I was due to buy anyway — and find an Internet connection somewhere. I could figure it out. But as time slipped by and I was still waiting, I started to get antsy. Since I didn’t know if this job would work out, I couldn’t really make any plans for something else. I half-heartedly applied for a job at the Grand Canyon again, but didn’t follow up. I didn’t want to go to the Canyon. I wanted to go to Washington. I wanted to try something new, have more free time, and fly my own helicopter. I wanted to open a new door.

So yesterday, when the phone didn’t ring, I was both disappointed and relieved.

Now I can make a real summer plan. And, at this point, it appears that it will involve Howard Mesa again.

I figured I’d go up there with Alex, Jack, and the horses again. But I’d also get involved with the Town of Williams. I’d get a business license there and join the Chamber of Commerce. Then I’d build a relationship with some of the local businesses and offer day trips by helicopter to Sedona and the Grand Canyon. If I got two or three flights a week, it would keep Zero Mike Lima flying and me out of trouble.

Best of all, it’s cool at Howard Mesa — generally 20 degrees cooler than in Wickenburg.

Which is a good thing, because there’s no air conditioning there, either.