O, what a tangled web we weave,
When first we practise to deceive!

Easing Some .htaccess Pain

Just wanted to post a quick tip that resulted from a Tweet from Jonathan Longnecker of FortySeven Media. He asked:

Anyone got Dreamhost to do 301 redirects in tandem with removing #eecms index.php? Weird query string stuff happening.

Well, having a bit of experience working with Dreamhost, I responded. This problem isn’t specific to ExpressionEngine, it actually will apply to any website or application where you are using .htaccess to rewrite index.php out of the URLs. Dreamhost and many shared hosts like it is are set up in such a way that .htaccess is always a bit more painful than usual, using the query string URI protocol. (Not that .htaccess isn’t painful to begin with.)

A typical .htaccess file on one of these hosts would look like this:

RewriteEngine On
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [QSA]

That works out fine until you want to add some 301 redirects into the mix. If you add a standard redirect like:

Redirect 301 /oldpath /newpath

You’ll find that instead of redirecting to www.domain.com/newpath, it ends up going to www.domain.com/newpath/?/oldpath, which isn’t good at all.

The key to fixing this is making sure that your index.php removal rule excludes your 301 redirects.

Just add this line after the RewriteEngine On line:

# put all your redirects inside the parentheses, separated by |s
RewriteCond $1 !^(old|old1|old2) [NC]

Hopefully that’s helpful to someone out there. Thanks to Jonathan for asking a question that I could actually answer.

Book Review: Building Websites with ExpressionEngine 2

I recently read through Building Websites with ExpressionEngine 2, by Leonard Murphy.

As one of the first books out to cover the relatively recently released ExpressionEngine 2, I was eager to get my hands on it. I’ve found before that reading through books, such as Michael Boyink’s, Building an ExpressionEngine 2 Site for Small Business, has been instrumental in developing a set of standards to use as I develop sites in ExpressionEngine 2.

In case you aren’t familiar with the product, ExpressionEngine 2, released in July of this year, is the latest release of EllisLab’s flagship content management system. The tool is extremely powerful, and is a top choice of web designers and developers for site-building projects that might otherwise resort the such CMSs as WordPress, Drupal, Joomla and the like. While ExpressionEngine isn’t free, and many of it’s top addons are commercial as well, they come with professional support, which more than makes up for the initial cost outset when you run into a bind along the way. ExpressionEngine allows you to work with your content in an entirely different way than other content management systems, completely separating it from the design, and this has led to a very active and dedicated fan-base.

With the power and flexibility of a complex and mature tool, such as ExpressionEngine, comes the challenge of working efficiently. In a wide-open playing field, one must set his or her own rules and standards, so that it’s easy to go back to a site you worked on several months ago and still know how it works. This has been the topic of sessions at the EECI conferences, such this one by Leevi Graham.

It’s in this area also, that I’ve found books such as Building Websites with ExpressionEngine 2 immensely helpful. Murphy’s new book is a good choice for the beginning ExpressionEngine user. It covers all the basics for a user who needs a little hand-holding. I appreciate that it also goes beyond the basics, with a chapter about implementing ExpressionEngine’s powerful membership features, both for control panel administration, and front-end site membership.

As any developer familiar with ExpressionEngine will tell you, one of the greatest features of the tool is its ability to be extended through add-ons. There’s a huge library of them available at Devot:ee, the ExpressionEngine community site, and it becomes a vital part of the development workflow to find appropriate add-ons for a given project. The end of the book includes an overview of several popular ExpressionEngine add-ons, which is fantastic. It’s extremely important to get a firm grasp of the available add-ons before really digging into ExpressionEngine.

While this book certainly isn’t the one for you if you’re already a seasoned ExpressionEngine user, I think any new user will find its contents valuable as they begin using the tool.

Introducing MojoAddons

This week an exciting thing happened. MojoMotor, the brand new content management system from EllisLab, makers of ExpressionEngine, was released.

I had been testing MojoMotor along with several other developers in the beta program and got a head start into working with the code. As a result Zack Kitzmiller and I set off on a path to build several much-needed addons for the new CMS. Along the way, we also built a really cool little site to show them off and sell them, as well as help to sell third-party addons from other developers. In the future we’ll also be adding third-party packaged themes for MojoMotor users.

So, with that, I’m happy to introduce MojoAddons.com.

If you’re trying out MojoAddons and using it for a project, I think you’ll find our addons are a great fit for making MojoMotor just a bit more powerful.

New URL Shortener

So, I’ve just updated my WordPress plugin to use my own homebrewed URL shortener, http://dpsh.me, when Tweeting about my new blog posts. How exciting!

It was a pretty quick little project to build the shortener a few weeks ago, and updating WordPress to use it was really easy too. I really should post the code somewhere.

Now, if Tweetie would just hurry up and release an update to the Mac client that includes custom shorteners like the iPhone client does.

The Fuel Podcast – Coming Soon

I’ve teamed up once again with the illustrious Jamie Rumbelow to make something new, fun and totally nerdy.

We’re currently working on a new podcast called The Fuel Podcast, specifically focused on the CodeIgniter community, but covering a broad array of web development topics that CodeIgniter and non-CodeIgniter developers all will be interested in.

We recorded our first episode last week, and Jamie’s currently working fervently to get our site up and running, so we can open The Fuel Podcast up to the world.

I’ll update when we’ve got something to show for our labors. It’ll certainly be an entertaining experience for all who chose to listen. Our sarcastic, slightly competitive and general nerdy humor will keep you on your toes while you hear us comment on the latest and greatest on the Web.