Ajax software
Free javascripts
↑
Main Page
which is authoritative. Many links have presumably built up over the years for both domain names, and
a search engine will have considerable difficulty ascertaining which version to index. The result is a
massive duplicate content problem. You could also take down the old domain, or put a page up on the
old domain indicating to users that they should visit the new domain. Both of these methods avert the
duplicate content penalty, but do not result in transference of link equity. The proper way to handle
such a necessity is to use a 301 redirect to the new domain.
Simply place this in your
.htaccess
file:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^old\.example\.com
[OR]
RewriteCond %{HTTP_HOST} ^www\.old\.example\.com
RewriteRule ^(.*)$ http://www.new.example.com/$1 [R=301,L]
This says that if a request for
old.example.com
or
www.old.example.com
comes in, it should be per-
manently redirected to
www.new.example.com
, keeping all the query string parameters. Note the way
the RewriteRule is only executed if one of the
RewriteCond
rules is satisfied.
Alternatively, you can assert something with another (similar) meaning:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.new.example\.com
RewriteRule ^(.*)$ http://www.new.example.com/$1 [R=301,L]
This says, similar to the canonicalization situation, anything that’s not the right domain should be
redirected.
URL Canonicalization: www.example.com
versus example.com
This is another topic that comes up again and again. Because every search engine (including Google —
even after the BigDaddy update) has issues when a web site is accessible under both
www.example.com
and
example.com
domains, we should be responsible webmasters and remove the ambiguity altogether.
Otherwise both versions may be indexed and cause duplicate content problems. This is a fairly simple task.
Simply place this in your
.htaccess
file:
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
This says that if a request for
example.com[path]
comes in, it should be permanently redirected to
www.example.com[path]
.
Alternatively, you can assert something with another (similar meaning):
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
91
Chapter 4: Content Relocation and HTTP Status Codes
c04.qxd:c04 10:40 91
Ajax software
Free javascripts
→