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.

My New (Old) Office

I move back to old quarters.

I spent much of today preparing to move my office back into my house. Late in the afternoon, Mike arrived from work and we loaded a bunch of stuff into the back of his pickup. I’m now typing this from my relocated office.

For the three and a half years, my office has been in a condo I own in downtown Wickenburg. I moved it there after the last tenant broke their 1-year lease and abandoned the place. When I discovered that nice white carpet (installed by the previous owner; I’m not a complete idiot, you know) completely trashed, I decided I was sick of tenants and sick of having a three bedroom house with only two occupants and no guest rooms.

We moved our offices to the condo in August 2003 (I think). It was nice to have a dedicate workspace, a place I had to go to to work. It got even nicer when DSL became available and I could get fast Internet.

But as time went by and I got more and more involved with my helicopter work, the downtown office became an inconvenience. If I had a call for a flight, I’d have to hurry home and get changed into normal clothes before driving to the airport. That was about 30 minutes shot to hell. And I started to get lazy, to not want to go to work in the morning. That’s not a good thing when I’m facing a deadline.

I wanted an office at Wickenburg Airport, but the powers that be in Wickenburg decided my small business wasn’t worthy. I guess I told too many truths on wickenburg-az.com. Made a few people feel uncomfortable. They decided to punish me by not letting me have an office at the airport. When I got the FAA involved — after all, the town’s agreement with the FAA has an “economic non-discrimination” clause — they started “cooperating” and finally got around to putting out an RFP for the 1000 square feet of land I had my eye on. But do I really want to be a tenant of the town? I thought so at first, but after dealing with the town’s crap for the past eight months, I’m pretty sick of it all and not very interested in giving the town any of my money. Frankly, most of my business comes from Scottsdale these days anyway. I’m still trying to decide whether to bid on the space after all.

So I decided to move my office back into the second bedroom at our house, the same room that was my office when we first moved here 10 years ago. It’s a 12 x 10 space with a nice, big closet. There’s no additional cost and a nice tax deduction for a home-based office. Best of all, I can go to work at any time of the day or night without commuting a single mile.

Mike’s office, which occupied the master bedroom of the condo, has been reduced to the size of a desk and set of shelves in the upstairs “den” where the television and stereo are. Not too shabby. He tunes into Sirius radio on Dish Network while he’s working and listens to it in surround sound. The window he faces has the best view in the house.

The view from my officeMy window also has a nice view. It looks out into the garden with the mountains in the distance. I just finished setting up the Webcam for wickenburg-az.com, which shows the view. Here’s the small view. (Well, if you’re looking at this during the week of January 22, you might actually be seeing the inside of KBSZ studios; there’s a tiny Webcam problem right now.) When spring comes, I’ll start working in the garden again. I’m looking forward to it. I miss gardening, but when my office was in town, I never seemed to have time for it.

Right now, 2/3 of my L-shaped desk has been moved into my office. My Dual G5 computer and the big 20-inch Sony monitor has been hooked up. I put the Dell speakers on the computer, but I think the old Altec Lansings sound better, so I’ll put them on tomorrow. I’ll get the last piece of my desk later in the week, after I clear space in this room for it. (Still got one of the old “library” shelves in here.) That’s also when I’ll bring in the printers and the Ethernet hub.

Other stuff that cluttered my office is gone. I sold the G4 that was my Web server — it sold for $335 on eBay yesterday and I shipped it out today — and I moved the G4 eMac to KBSZ studios for audio streaming. Today, I disassembled the Dell Dimension L933r computer that was my old PC test mule in preparation for donating it to the local library. My old Strawberry iMac (a G3) is in the garage, waiting for me to restore it to factory settings and dispose of it. I gave my old clamshell iBook SE to my next door neighbor, who is home-schooling her four young kids. She now has her own “computer lab.”

That leaves me with a very reasonable 3 computers for my work: my Dual Processor G5 (now about 3 years old), my relatively new Dell Latitude D820 laptop test mule, and my reasonably new 15″ Mac Book Pro test mule. Oh yeah, and my 12″ G4 PowerBook, which I really can’t part with. No need for all the desk space I had in my downtown office. I’m even cutting myself down to two printers (rather than the 3 I had accumulated). Look for some new items on eBay soon.

Getting rid of all this old equipment feels good. Although I actually threw away — in a Dumpster! — three external SCSI hard drives and a dual bay SCSI CD-ROM reader today, most of the other equipment is finding a good home. I hate throwing stuff away, but I really hate storing it. And let’s face it: old computer equipment has very little value these days.

So now I’m sitting at home in my office at 8:25 PM, listening to iTunes music on my G5 (right now: “Wish You Were Here” on Wish You Were Here by Pink Floyd). It’s later than I’d usually be working. I think I’ll be working longer hours with my office in the house. Getting more work done. Blogging more.

And doing a lot of work in my pajamas once again.

5 Tips for Staying Focused

Some things that work for me.

I’ve been having trouble staying focused on my work these days. It seems that the number of distractions at my desk exceed the number of reasons I should work on my current work-in-progress, Excel 2007: Visual QuickStart Guide.

I’ve come up with a few tips that help me stay focused on a specific project or task. You may have heard some of these elsewhere; I’ve been reading a lot of about productivity tricks lately and have been linking to other articles. But this is my take on these techniques — whatever that’s worth.

  1. Organize your workspace so it has everything you need to work on the project — and just that. If you’re as likely to succumb to distraction as I am, anything handy that’s unrelated to the task at hand will pull you away from it. Ditto if you have to get up and get something that you need that’s not handy, especially if getting up takes you past the fridge, the phone, or any other distraction.
  2. List the steps you need to complete to get the job done. Think the job through before you begin so you know what has to be done. Amend the list as you work. Before starting any task that’s not on the list, ask yourself if it’s really part of the project. If so, add it to the list and do it. If not, don’t be tempted.
  3. If you don’t need an Internet connection to work on your project, turn it off. That’s as easy as turning off your AirPort card (on a Mac), unplugging your Ethernet cable, or turning off/unplugging your router. One tip I read online recently suggested using a light timer to turn off the router for a certain amount of dedicated work time each day. Personally, I like to be more flexible.
  4. Don’t check your e-mail. If you have to keep your Internet connection turned on for your work, don’t run your e-mail application. If you do and it checks e-mail periodically (as most do), you’re very likely to be distracted by an incoming e-mail message. I know I always am. Best to not to run your e-mail application at all.
  5. Don’t run applications you don’t need to get the job done. That includes (especially) Web browsers and other distracting applications. If you’re often tempted with games and are fortunate enough to have more than one computer, delete every single game you have from your work machine so you can’t be tempted to play when you should be working.

Remember, I work alone in an office, so I’m not usually distracted by other people. If you have distractions from others, be sure to check out “18 Ways to Stay Focused at Work” by Dave Cheung. His article includes some tips for keeping co-workers from ruining your productivity.

Broadband Available at South Pole

But not at my house in Wickenburg, AZ.

According to Wired, high speed broadband Internet access is now available at the Amundsen-Scott South Pole Station.

Can someone please explain to me why my Bluewire Internet connection at home — the only “high speed” connection available to me here — clocks in at a whopping 220 kbps? In Wickenburg, AZ? Right here in the U.S.A?

I’m a bit closer to the backbone here, no?

Speakeasy Speed Test

See your real bandwidth.

When you set up your Internet connection with an ISP, you don’t need to believe what they tell you about bandwidth speeds. You can check it for yourself.

Although there are many bandwidth testers on the Web — your ISP probably provides one — I use one called Speakeasy Speed Test:

Take the Speakeasy Speed Test and test your connection speed! By measuring the download and upload rate from the following locations you are able to accurately judge your current line throughput or internet connection speed. To take the speed test, choose the server nearest you.

Speakeasy Speed TestThe Speed Test displays your results graphically using a speedometer-like meter. Here’s an example of what my terrible home Internet connection looks like with the upload test in progress. (Now you can see why I don’t want to move my office back home. I can just about pin the speed needle with my DSL connection at the office.) At the end of the test, Speakeasy plays a little advertisement and offers access to a search feature where you can see if their service is available in your area. (It’s not in my area, but then again, there’s only one non-dialup option available for my home and you’ve seen the results.)

While I’m not recommending Speakeasy — I know nothing about it — I do recommend this test. If you know of any others, don’t be shy. Use the Comments link to share them with the rest of us.