The Definitive Guide to Apache mod_rewrite (A Book Review)

A couple of weeks ago, I was sent a review copy of “The Definitive Guide to Apache mod_rewrite” by the lovely people at Apress. The book promised to be the be-all and end-all guide to the mod_rewrite module, and overall it succeeds.

Rich Bowen (also author of Apache Server Unleashed, The Apache Administror’s Handbook and The Apache Cookbook) clearly knows his stuff and guides the reader through the module with ease, introducing key concepts as he goes. There are times, however, when to me the book feels as though it is aimed just a bit too much at the beginner to be a truly definitive guide to the module. This doesn’t mean I don’t like the book though - I think it’s fantastic and it really should be on everyone’s reading list if they’re seriously wanting to learn how to use mod_rewrite.

The book assumes absolutely no prior knowledge of the mod_rewrite module, and is broken up into an easy to digest 12 step programme which will get you using the module in no time at all. Here’s how those chapters look:

  1. An introduction to mod_rewrite

    Here, Rich talks about what mod_rewrite is and why on earth you’d decide to use it at all. He also starts hammering home the gospel that mod_rewrite should not be used all the time - there are plenty of circumstances where it makes much more sense to use something else.

  2. Regular Expressions

    This second chapter is very useful if like most people, you’ve never used a regular expression before. Even if you feel you’re pretty handy with the regex spanner in your toolbox, it would probably be a good idea to skim this chapter and maybe pick up a pointer or two that you’d not known about before.

  3. Installing and Configuring mod_rewrite

    If you’re runnning your own server then this is going to be of interest to you. If, on the other hand, you’re just running a website on a shared server then it probably isn’t. It does show you a couple of ways to test whether mod_rewrite is installed and working though.

  4. The RewriteRule Directive

    Ah, here we go - chapter four is where we start actually doing something with mod_rewrite! The RewriteRuleis looked at in depth here, and a big chunk of the chapter is given over to the various flags that can be used with it.

  5. The RewriteCond Directive

    Chapter five looks at how we can use logic to determine whether or not a RewriteRule should be executed. It’s only ten pages long, but the content is incredibly valuable.

  6. The RewriteMap Directive

    Again, this chapter is not going to be a huge amount of use to people who run their websites in a shared environment and don’t have access to the Apache configuration file, since RewriteMap cannot be used within a .htaccess file.

  7. Basic Rewrites

    Half way through the book, it finally gets onto some meaty examples of how to use mod_rewrite.

  8. Conditional Rewrites

    Continuing on from Chapter seven, in this chapter we get a good section of examples of using RewriteCond to determine which RewriteRules should be run.

  9. Access Control

    The examples start coming thick and fast now, as this chapter shows you how to use mod_rewrite to control access to your website. More importantly, it also shows you when you shouldn’t use mod_rewrite to do this.

  10. Virtual Hosts

    Another chapter that’s going to be of no use to those people who are running their websites in a shared environment, this one will be of great use to those systems administrators who have to look after hundreds or even thousands of virtual hosts on a day to day basis.

  11. Proxying

    This chapter helped me out at work just after I read it. Essentially, it shows you how to use mod_rewrite as a proxy to transparently redirect to multiple back end servers for load balancing and the like.

  12. Debugging

    The final chapter shows you where to go when all else fails and things don’t work quite the way you expected and teaches you how to use the RewriteLog.

All in all, I think that “The Definitive Guide to Apache mod_rewrite” really is that - a definitive guide that will get people off to a fantastic start with the swiss army knife of Apache modules. A definite must buy if you’re going to be doing anything with mod_rewrite.

permalink | View blog reactions

other relevant pages

about wwm

workingwith.me.uk is a resource for web developers created by Neil Crosby, a web developer who lives and works in London, England. More about the site.

Neil Crosby now blogs at The Code Train and also runs NeilCrosby.com, The Ten Word Review and Everything is Rubbish.