Today I read Matt Cutts‘ post about URL Canonicalization, and decided to finalize my URL structure. I implemented my canonicalization with mod_rewrite in Apache. I found a helpful introduction to mod_rewrite.

So which is better: or For some time, I preferred the former, simply because I didn’t like the way the latter looked in the address bar. But now, I have settled on the latter, simply because I feel it’s more semantic and RESTful. The subdomain www implies the web component of joshuamclark, but I want my URI to identify all of joshuamclark, not just one component. That is, I want my URI to be more semantic. This will make it easier for any user agents to access me in a representation they can understand. That is, I want your stay at to be utterly RESTful.

I then decided to disallow /index.php as well. It 301’s to /.

So I was able to implement these rules with a few simple lines in .htaccess:

Options +FollowSymLinks 
RewriteEngine on 

# Redirect /index.php to /
RewriteRule ^index\.php$ [L,R=301]

# Redirect to
RewriteCond %{HTTP_HOST} ^www\.joshuamclark\.com$
RewriteRule ^(.*)$1 [L,R=301]

%d bloggers like this: