Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have several domains running under apache. Most of theme they do not have yet virtualhost. My problem is that all this not registered domains by apache are getting redireted to the setup domain. How to force apache to accept request just from the domain.

what I mean

<VirtualHost *:80>
        ServerAdmin info@mydomain.com
        ServerName mydomain.com
        ServerAlias mydomain.com www.mydomain.com
        DocumentRoot /var/www/mydomain.com/
        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory /var/www/mydomain.com/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>

than I have for example domain1.co.uk, domain2.org all are redirected to mydomain.com. This should be avoided

if I use wildcar like ServerAlias *.domain1.co.uk and I have subdomain svn.domain1.co.uk than the svn subdomain is going to be redirected to domain1.co.uk

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Add a default virtualhost, like this:

<VirtualHost _default_:80>
    ServerName example.com
    ServerAlias *.example.com
    DocumentRoot /var/www/htdocs
</VirtualHost>
share|improve this answer

You just have to add your domain names in the ServerAlias directive's list an configure each DNS zone to resolve as your Web server.

share|improve this answer
    
and what about if I have for example for mydomain.org a subdomain (test.mydomain.org) in this case the wildcard (.*) won't work –  fefe Apr 24 '13 at 20:11
    
In ServerAlias, you can specify *.mydomain.org if this is what you mean. –  Spack Apr 24 '13 at 20:29

Your Answer

 
discard

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.