Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can across a issue where I saw some is pointing to I am not using Apache, nor IIS but Tomcat 7 directly.

How to I avoid such other spam domains pointing to

I read across some posts setting by virtual hosts etc, but nothing specific of how to avoid it. I searched on Google but most answers are for HTTP servers and no exact answer for tomcat 7.

share|improve this question
up vote 3 down vote accepted

You can't in any way stop anybody else from pointing to your webserver. What you can do is to server up a web site that will inform people that the domain is not hosted by you. There's some information about how virtualhosts work at the Tomcat documentation site.

If we assume that you have two domains that you want to host, and anything that doesn't match them should be shown the same "this domain doesn't live here" page, you'd have your first <Host ...> item be <Host name="localhost" ...>. That will be the default site loaded when there's no other site that matches. Then you'd add another <Host ...> for each of the domains that you actually want to serve.

In order to have the same content for two domain names, e.g. with/without "www", you use <Alias></Alias> within the <Host> element.

And, for the "not my domain" page, you just create a separate application directory containing suitable web pages, and have that as the appBase for the "localhost" virtual host.

share|improve this answer
yes but www.mydomain also does not work if i keep name="mydomain" – Amol Ghotankar Apr 2 '13 at 12:41
Adding that to the response. – Jenny D Apr 2 '13 at 12:48
Thanks @Jenny - one more thing - Can we have not my domain to redirect to my domain? Will this affect SEO of my content? Can I use alias for and other mydomain tld's? – Amol Ghotankar Apr 2 '13 at 13:06
You can use as many alias as you like, for all domains that have the same content. I'm not sure about SEO, but I don't see that it should be affected at all. – Jenny D Apr 2 '13 at 13:22

You can't. You don't control the other domain, and they can put whatever they want as the target of the CNAME or A record(s). The only thing you can do is refuse to serve the domain by making use of the virtual hosts in the documentation you found earlier.

share|improve this answer

Your Answer


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.