In my quest for arbitrary and useless lexical elegance, a couple years ago I decided on a /%post_id% permalink structure for my blog. So all the URLs were of the structure http://blog.johnjosephbachir.org/330. Since then, Ben has convinced me that a /date/title structure is the way to go, as it provides orientation for the user in terms of where the content came from. Also, it allows me to never worry about my permalink structure changing again, in terms of namespace etc.
Another benefit, as noted on the claimid blog a few months back, is that search engines put value in the strings that are found in URLs. So there is a SEO benefit in having title slugs in urls.
I changed the permalink structure in the WordPress control panel, but to get permanent 301 redirects from the old URLs to the new, I needed to use Apache mod_rewrite. Here is what I came up with:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)/?$ http://blog.johnjosephbachir.org/?p=$1 [R=301,L]
</IfModule>
# below are the standard WordPress rewrite rules
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
A similar, but different approach (due to a different permalink change scenario) can be found in my last post on this topic here: fixing-broken-links-in-wordpress-after-changing-the-permalink-structure.html