Top Nav

Canonical Rewrite Rules

Here’s a good rule set for forcing use of a preferred url:

This version of the canonical rewrite expands on the original found here:

http://httpd.apache.org/docs/2.2/rewrite/rewrite_guide.html#canonicalhost

by adding:

  1. redirects domains with suffixes (not just prefixes) back to the canonical host; and
  2. allows Host request headers to contain port specifiers (which is allowed by RFC2616 section 14.24)

as suggested here:

http://colby.id.au/node/99

and by using a 301 redirect as recommended by Google here:

http://www.google.com/support/webmasters/bin/answer.py?answer=44231&hl=en