I noticed that Google somehow indexed my site but with incorrect subdomain. Instead of putting a link to www.mydomain.com or mydomain.com it shows ns1.mydomain.com and ns2.mydomain.com, which results in broken images, because I used relative paths.

Now, I don't even have ns1 and ns2 setup as subdomains. I have those in my DNS settings.

So, how do I go about redirecting users to the correct address?

Thanks

Accepted Answer

OK, I think I was able to fix this by placing this into my .htaccess file

RewriteCond %{HTTP_HOST} ^ns1.mydomain\.com
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=permanent,L]

But even though I fixed it, I am very curious how did Google index those links anyway?

Written by santa
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki