joshuamclark.com Canonicalization

28Mar07

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: http://www.joshuamclark.com or joshuamclark.com? 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 joshuamclark.com 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$ http://joshuamclark.com/ [L,R=301]

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


%d bloggers like this: