Forum Moderators: phranque
Firstly, can anyone think of any reasons why this might affect our SERPs? We were wondering whether we risk being penalised by Google for duplicate content if Googlebots found links to incorrect subdomains on our website.
Secondly, does anyone know of an .htaccess hack which will return a 404 page to a user who tries to request a page from a non-existent subdomain?
Many thanks
Chris
[edited by: engine at 6:23 pm (utc) on Feb. 5, 2007]
[edit reason] examplified [/edit]
Welcome to WebmasterWorld!
You never know whether a link to a 'bad' subdomain is a malicious ploy by a competitor to cause duplicate-content problems for you, or simply a typo -- either on a link from a site that might be worth having, or as a result of a direct browser address bar type-in error. In all but the first case, a 404 is a 'sudden shock' to the user and therefore, inappropriate.
The simplest and safest solution is to issue a 301-Moved Permanently redirect from the incorrect (sub)domain to the requested page on the correct domain. This, along with www- vs. non-www canonicalization can be accomplished using a single rule in mod_rewrite. An example for use in httpd.conf is:
# If not canonical domain
RewriteCond %{HTTP_HOST} !^www\.example\.com
# Redirect to requested page in canonical domain
RewriteRule ^/(.*)$ http://www.example.com/$1 [R=301,L]
Jim