At work, we’re looking at a major webpage redesign, and are therefore looking at other similar programs and their websites to see what they are using… and one major thing has struck me in the process. No one uses redirects to force certain URLs. For example: http://www.staze.org vs http://staze.org. Now, in one case, both work, and they present the same content (bad for SEO), in the WORST case, one works, and the other doesn’t. Almost none of the sites we looked at handled this correctly.
Really, it’s extremely easy to fix. Either in .htaccess, or in your virtual host file, just add something like:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^localhost [OR]
RewriteCond %{HTTP_HOST} ^127\.0\.0\.1
RewriteRule ^(.*) – [L]
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule ^/(.*) http://www.example.com/$1 [R=301,L]
UPDATE: Please see the corrected code above to account for anything referencing your site on the local machine via localhost, or 127.0.0.1…. some of my site broke without me noticing until today. DOH!