0

I have a VPS that hosts several domains. I have set up Apache in the following manner:

First VirtualHost

/etc/apache2/sites-available/somedomain.com

<VirtualHost somedomain.com:80>
    ServerName somedomain.com
    ServerAlias www.somedomain.com
    ...
</VirtualHost>

Second VirtualHost

/etc/apache2/sites-available/someotherdomain.com

<VirtualHost someotherdomain.com:80>
    ServerName someotherdomain.com
    ServerAlias www.someotherdomain.com
    ...
</VirtualHost>

Then I symlink the config files from sites-available to sites-enabled and all is well.

I had a need to 'turn off' someotherdomain.com, so I removed the symlink to /etc/apache2/sites-available/someotherdomain.com from sites-enabled and the site no longer shows up... BUT typing someotherdomain.com into a web browser brings up somedomain.com!!! I need it to not resolve at all.

Does somethiing need to be done in the VirtualHost to just automatically return a 500 or something along those lines. I really don't want people to reach one website from a different domain.

Thanks!

EDIT

ports.conf looks like this

NameVirtualHost *:80
Listen 80

<IfModule mod_ssl.c>
    NameVirtualHost *:443
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>
6
  • Did you reload Apache? Jun 3, 2014 at 20:45
  • You mean sudo service apache2 restart? Yes, several times. Even did a server reboot or two since I made these changes. Jun 3, 2014 at 20:46
  • I am assuming this is Ubuntu/Debian? What does your /etc/apache2/ports.conf look like? Do you have an appropriate Listen and NameVirtualHost options set? Also, IMO you should be using the IP in your <VirtualHost ...:80> blocks rather than the name.
    – Zoredache
    Jun 3, 2014 at 21:01
  • Edited to add ports.conf Jun 3, 2014 at 21:12
  • OK, so what changes did you make to the DNS records for the domain being moved? Jun 3, 2014 at 21:13

1 Answer 1

3

If you don't want it to resolve at all, you need to delete the host from DNS.

Otherwise Apache will deliver the first vhost instead and you can't turn this off. To prevent this, you need to configure either a dummy vhost with e.g. just a blank index.html or configure it to deliver an error message (e.g. 404).

3
  • That makes perfect sense! I was hoping that if Apache couldn't match the request to a VirtualHost it would simply ignore it. There's no way to make that happen? Jun 3, 2014 at 21:23
  • 1
    No, unfortunately not. I am not sure why as this is a quite common problem.
    – Sven
    Jun 3, 2014 at 21:24
  • I just changed the VirtualHost directives to point to a 'maintenance' type page and re-symlinked them. After restarting Apache, it went right to that page. Thanks!! Jun 3, 2014 at 21:28

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.