Nathen Harvey

a blog

Testing Mod_rewrite and Apache Redirects

At CustomInk, we recently migrated from mongrel to Passenger for our Ruby on Rails website. This migration included a full rewrite of our apache configuration files.

With over 500 redirect and rewrite rules in place I needed a way to ensure my copy-n-paste skills were up to snuff and that we didn’t loose any redirects along the way.

In my search for help, I found a blog post by Patrick Reagan from Viget labs that described a method for writing tests that will verify all the rewrite rules and redirects. Patrick’s ideas were packaged up into a gem and available on github.

I can now write up tests like:

should_redirect "/cink/ideas/ideas.jsp", :to => "/inspiration/"

So now I can to some TDC (test-driven configuration) whenever I get a request for a new redirect.

What other methods have you used to test your rewrite rules?

Passenger and PHP

I recently migrated a site from mongrel to passenger. Today I learned that the wordpress site that was served up by the same webserver wasn’t working anymore.

Compared the configurations and everything looked OK, no changes were made as part of the migration. PHP module was being loaded, URL was being properly aliased, etc. Watched my logs and saw that Passenger was attempting to serve up the request which is not what I wanted.

A quick update to my Directory’s definition and the issue was fixed. I had to explicitly disable Passenger using PassengerEnabled off as seen below:

  Alias /blog /shared/www/blog
  <Directory /shared/www/blog>
    DirectoryIndex index.php
    PassengerEnabled off