It’s a good thing that I have Caleb’s photo on my desktop and Chesney’s photo sitting on top of my montior because they reminded me that I have something to live for. After hours of staring at Perl regular expressions, I came very close to putting my head through my monitor.
If this makes perfect sense to you…
RewriteRule ^/?([^/.]*)/?([^/.]*)/?$ index.php?var1=$1&var2=$2 [L]
…then you are a geek. This is a rewrite rule using dreaded mumbo-jumbo called Perl regular expressions.
This all started when I started looking at timches.com’s stats and finding that I wasn’t getting as many hits after the redesign. I found the culprit to be the new dynamic pages. Apparently, search engine robots don’t like GET variables found in urls like:
I used rewrite rules in .htaccess files to create an alternative “static” link:
The rewrite rule to make that static link happen is just one line:
RewriteRule ^([0-9]*)/([0-9]*)/([0-9]*)/([a-zA-Z0-9_]*).html show_album.php?id=$3&y=$1 [L]
Here’s several sites that I found helpful in learning how to do this (and for my future reference as well).
- Mod_Rewrite Tutorials Board
- Regular Expressions Cheat Sheet
- Mod Rewrite Tutorial at DevShed
- URL Rewriting Guide
So now I sit and watch to see if indeed this helps my search engine rankings. If it doesn’t, well, that’s why I have Caleb and Chesney’s pictures close to my monitor.