This is an archive site. For the recent posts, visit orderedlist.com.

Ordered List

OrderedList

May 26 2005

An Underscore Solution

Hopefully this will be the last post on this topic for a while (I know it’s not the most interesting thing to discuss), but I’ve finally made up my mind on the subject. After doing some more in-depth research on the dash/underscore debate over the last week, I’ve decided that the benefits to URI-dashes do outweigh my stubbornness and personal preference for the underscore. So I’m making the switch. As of now, all future URI’s on this site will be dash-friendly. In addition, all past URI’s have been updated, and the old underscored-URI will be 301’d (Permanently Redirected) to it’s updated location.

All this means is that all hard-coded links to pages on this site with an underscore in the URI will continue to work, and always will. But the 301 redirection should update all search engine records, so Google and others will get a fresh load of easily-searchable URI’s to replace their current stock.

All of this is controlled by a single WordPress plugin I wrote this evening. I figure it might help people transitioning from Movable Type to WordPress, or anybody who uses WP with the underscore in their URI’s wanting to switch to the dash, so it is available for download.

The plugin does two things. First, when activated, it immediately applies a filter to the start of every WP page load. This filter checks to see if the current instance is a Page or Post, and if so, checks to see if the requested Page/Post is valid. If not, it examines the database for the Page/Post with the same title, just replacing any underscores with dashes. If the result of this query is valid, it spits out a 301 Permanent Redirection header, and redirects the browser to the updated URI. Second, the plugin includes an options page that includes a simple button to globally search-and-replace any Page/Post slug underscores with dashes. So all you have to do is load the plugin, activate it, then click the button on the options page, and you’ll be all set.

As to my partiality to the underscore, perhaps I will learn to love the dash in due time. I still prefer the looks of the underscore, but I’m able to admit when a preference goes against more logical evidence. So Google, I shake my fist and add one to your tally. You’ve won this one. Just don’t let it go to your head.

Download the Dash Redirect plugin.