Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

In my site I prefix the images and links with the domain of the site for better SEO using the code below:

public static string GetHTTPHost()
        {
            string host = "";

            if (HttpContext.Current.Request["HTTP_HOST"] != null)
                host = HttpContext.Current.Request["HTTP_HOST"];

            if (host == "site.co.uk" || host == "site.com")
            {
                return "http://www." + host;
            }

            return "http://"+ host;
        }

This works great, but for some reason, lots of links have now changed to http://www.baidu.com/...

There is no sign of this in any of the code or project, the files on the server also have a change date when i last did the publish at 11 yesterday, so all the files on there look fine. I am using ASP.net and Umbraco 4.7.2

Does anyone have any ideas? thanks

share|improve this question
1  
Try checking your site from another computer or (at very least) another browser -- maybe your computer just got some nasty software installed that does this. If that is not the case -- then worth checking IIS configuration (and web.config files in particular) -- maybe links got overwritten using URL Rewrite Module (it can rewrite incoming and outgoing links). –  LazyOne Oct 30 '12 at 11:26
1  
Moot point, but making all internal URLs absolute has no effect on SEO. However, it possibly hampers someone who is attempting to copy your site. –  w3d Oct 30 '12 at 12:21
1  
I know, but marketing people love to say they know best! –  Funky Oct 30 '12 at 14:22
    
Disable the antivirus/firewall, restart machine (don't let antivirus start). recheck it again. –  articlestack Apr 24 '13 at 11:44
add comment

1 Answer

Anybody can point a domain name to the IP address that you are using for your site. I also see DNS servers get the wires crossed occasionally and they think that other domain names point to my website when they actually don't. I would suggest putting a whitelist of domain names that you expect into that function. If the hostname isn't one of the allowed host names, change it to your default host name or show an error message.

I have taken the approach on my server of showing an error message with a 400 status code.

400 Bad Request

This server is not configured to serve documents for 'foo.example.com'
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.