Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

My Apache Server IP address is 192.168.1.100 and the Domain Name is test.local.

  • If a user types in the URL, say "http://test.local", then they should be allowed.
  • If a user tries to access "http:// 192.168.1.100" then they should be denied.

How can I accomplish this?

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

What you want to do is name-based virtual hosting, so something along these lines might get you started, I believe:

NameVirtualHost *:80
<VirtualHost *:80>
  <Location />
  Order deny,allow
  Deny from all
  </Location>
  # other configuration for default host...
</VirtualHost>

<VirtualHost *:80>
  # This is the one you would like visible
  ServerName test.local
  <Location />
  Order deny,allow
  Allow from all
  </Location>
</VirtualHost>

(I'm in a bit of a hurry, so there might even by typos in there, sorry.)

share|improve this answer
1  
I suggest adding an explicit _default_ VirtualHost entry. –  gertvdijk Dec 20 '12 at 14:17
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.