Mobile app version of vmapp.org
Login or Join
Welton855

: Links in my site have been hacked 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()

@Welton855

Posted in: #AspNet #Iis7

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 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

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Welton855

1 Comments

Sorted by latest first Latest Oldest Best

 

@Heady270

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'

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme