I’ve got a server hosting multiple websites. Server is written in Java+Jersey.
If someone makes his DNS point to my service, but this DNS doesn’t match any of my hosted websites, what should I answer? Note that I need to do this programmatically and can’t rely on some customization of my Web container ( Tomcat ) .
The problem is, if I display a « website not found » page, I shall have search engines reference my primary domain website under a false name, therefore downgrading its page rank because of someone else’s mistake.
I tried to change my /etc/hosts file to reproduce the behaviour but can’t guess what other websites are doing in this case too.
Any idea ? A simple 404 seems too light ? Bad Request seems inappropriate …
Definitely a 4xx, since the error comes from the request (the
Hostheader contains an invalid value).I would say 404, Not found is probably the best answer here. This will prevent indexing from search engines.
Another solution could be to redirect (permanently) to the main domain of your website? I have seen this behaviour a few times.