Canonical Rewrite Rules
Here’s a good rule set for forcing use of a preferred url:
|
1 2 3 |
RewriteCond %{HTTP_HOST} !^desired\.domain\.name(:.*)?$ [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^/?(.*) http://desired.domain.name/$1 [L,R=301] |
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: redirects domains with suffixes (not just prefixes) back to the canonical host;




