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.

How to restrict users to go to my site only by using the domain name not by the IP address.

example.
WWW.fun.com - allow
http://172.20.145.78 - don allow.

Please help

share|improve this question

migrated from webmasters.stackexchange.com Jan 18 '11 at 12:52

This question came from our site for pro webmasters.

2  
what web server are you using? –  JP19 Jan 18 '11 at 11:17
1  
Since this is a web server configuration issue, it should probably be posted on serverfault. Also, the "accessibility" tag is a bit misleading here. –  Lèse majesté Jan 18 '11 at 12:29

2 Answers 2

Set a virtualhost name-based. If you are using apache, read this.

share|improve this answer
NameVirtualHost *:80

<VirtualHost _default_:80>
ServerName ip.add.re.ss
DocumentRoot /path/to/somewhere/else
<Directory /path/to/somewhere/else>
Order deny,allow
Deny from all
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerName www.fun.com
ServerAlias fun.com *.fun.com
DocumentRoot /path/to/your/webroot
</VirtualHost>

That should do it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.