Humans first, please

March 4, 2009 —

If you’re doing it right, your goal is never to build an SEO-friendly site. It’s to build a usable site. The latter leads to the former. Not the other way around.

This isn’t to say SEO doesn’t work. It’s only to say SEO is a hack.

Rewriting URLs

October 1, 2007 —

In my previous post, I mentioned Apache mod_rewrite lets you take a URL like:
http://yoursite.com/products/index.php?cat=software&item=Photoshop
and convert it to something like:
http://yoursite.com/products/software/Photoshop

There are two main benefits to formatting URLs the second way.

  • it’s easier for visitors to read.
  • it’s easier for Google to index.

You also gain a number of positive side effects, one of which is the ability to keep your variables hidden. Basically, the only reason not to rewrite URLs is the added effort required to do it. But, what if the added effort really wasn’t that significant?

It’s not.

First, let’s assume my earlier mention of Apache already turned off anyone not using it (if your rewrite engine doesn’t match mine, I’m no good to you.) Let’s also assume those who already know how to do this (and probably better than I) already got bored and moved on.

Okay, now if you’re still with me, all you need to do is create an .htaccess file in the directory you’re looking to rewrite (/products/ in my case) with the following lines:

RewriteEngine on

#Rewrite for software categories
RewriteRule ^([^/\.]*)/([^/\.]*)/?$ index.php?cat=$1&item=$2 [L]

Variables work the same, queries work the same, etc. It’s a lot like magic.

That’s it friends. Hi5.