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 to close access to website by ip (close access via http://203.0.113.11), but access via domain should be still available.

I've read http://httpd.apache.org/docs/2.0/vhosts/name-based.html (section Using Name-based Virtual Hosts), configured as recommended:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain
</VirtualHost>

restarted httpd, but this VirtualHost is still available by ip.

What am I doing wrong?

share|improve this question
    
Changed IP address to one within an RFC 3330 TEST-NET example range. –  Skyhawk Apr 19 '12 at 20:41
add comment

1 Answer

up vote 5 down vote accepted

Your apache will always use the first virtualhost as the default one.

So before any other vhosts, create another one that points to whichever you want to show all visitors hitting a hostname that doesn't exist within a virtualhost config.

share|improve this answer
    
Thank you! I've added VirtualHost with <VirtualHost *:80> DocumentRoot "/home/blogs/" <Directory "/home/blogs/"> Order Deny,Allow Deny from all </Directory> </VirtualHost> –  Kirzilla Apr 19 '12 at 20:35
add comment

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.