I am using Apache 2.2 on a Debian-based distro. For some reason, all URLs are directed to the default index. No error or anything. That means: example.domain.com goes to domain.com. "example" can be just anything. In the default Vhost file (/etc/apache2/sites-available/default) I've added:

ServerName: www.domain.com

But it still keeps that odd behaviour. Please let me know how to enable the common, default behaviour. I haven't changed anything by the way, this is since installation.

Update: Following SvW's answer, I am looking for a way to force Apache not to accept any URL, only those specified as VirtualHosts.


The primary "problem" is that you have a wildcard DNS entry pointing to your web server, otherwise you would get an "unknown host" error from your browser. Remove that and this will stop (after the TTL of the entries is expired, up to 24h hours later).

Apache itself will always use the first vhost definition to answer requests for host names not defined in other vhosts.

|improve this answer|||||
  • I am using DDNS, and I the provider doesn't let me control DNS entries. Is there a way to tell Apache to ignore any prefixes not defined? – Ariel May 31 '14 at 13:09
  • 2
    Not that I know of. You could write a special first vhost that does nothing else than to either throw an error or redirect requests to your real site. In my opinion, the solution is to switch to a provider that lets you control the domain that you own. – Sven May 31 '14 at 13:11

Any request which does not match a specific vhost will be sent to the default vhost by Apache.

The solution I recommend is to create a default vhost before all the "real" ones. This default vhost should not match any of your domains, and should reply with an error code on every request. I think 404 would be an appropriate answer from this vhost.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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