I had to do it. It's been bugging me for a long time now. I had to update my site's URLs. More specifically, I had to update my site's article URLs (along with some others). I've been putting this off for a long time because I knew it was going to be a lot of tedious work updating all my URLs and adding a whole bunch of rewrite rules. Well, I finally forced myself to sit down and do this. Prepare for mass breakage.
Well, hopefully not. One thing I changed was my Archives URL. I basically just pluralized it to have it match its sub-pages (topics and tags). I also wanted to carry this same naming scheme across to the Articles page, and changed the URL from article to articles. Neither of these were a big deal. My CMS (NiBuM) easily allows you to change the URLs of your pages. I also created some simple rewrite rules in my .htaccess file to redirect anyone (search bot) to the new, correct URL.
Next I needed to change my individual article URLs or permalinks. In the past my permalinks were separated by underscores (_). So they looked like this: http://webnv.net/articles/url_friendly_article_title
I don't know why I originally designed the system like that. Maybe because I believe underscores are a better visualization for spaces than any other character (not including actual spaces of course). But I've always noticed other URL friendly sites would use hyphens (-) instead of underscores or plus signs (+). And after reading several articles about which character is the best, it turns out hyphens are the best, and are recommended over underscores.
Why hyphens over underscores?
The reason is because a lot of programming languages use underscores in their syntax. I know PHP uses tons of them - mysql_num_rows - being an example. With certain search engines the underscore represents a literal character and not something that can represent a space. So when a search engine indexes your site, they may have trouble breaking up the URL into separate words. The hyphen is the recommended alternative for representing spaces.
I'm sure search engines have since come a long way and probably don't have a hard time with underscores like they used to. But to be safe and keep in line or standard, I've updated all my article permalinks to use hyphens instead. This of course would break virtually every search index, bookmark, favorite, etc. that was pointing towards the old, underscored, URL. Using the .htaccess file again, I created some rewrite rules to fix this.
So if anyone out there has any bookmarks or favorites, you might want to update them accordingly. While the rewrite rule will get you to the correct page, I don't want to keep these rewrite rules in my .htaccess file forever. So, when they're gone, expect mass breakage.

March 13, 2008 2:51 pm
1001 Views

Team Fortress 2 is like alcohol
Be the first to comment by using the form below.