apache2 default namevirtualhost

Posted by Zulakis on Server Fault See other posts from Server Fault or by Zulakis
Published on 2012-09-22T12:32:59Z Indexed on 2012/09/22 15:39 UTC
Read the original article Hit count: 374

I got a site server.com which I want to be returned when it is directly adressed using server.com or www.server.com but issue a 404 if the webserver gets accessed using its ip or another hostname.

I got something like the following:

NameVirtualhost 10.0.0.1:80
<VirtualHost 10.0.0.1:80> #This should be used if Host is server.com or www.server.com
ServerName server.com
ServerAlias server.com www.server.com
DocumentRoot /var/www/
</VirtualHost>

<VirtualHost 10.0.0.1:80> #This should be used alternatively
RewriteEngine On
RewriteRule (.*) - [R=404]
</VirtualHost>

How can I now set that the second entry should be used if hostname is not server.com or www.server.com?

© Server Fault or respective owner

Related posts about apache2

Related posts about virtualhost