Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

In Apache, How do i disable access to a website when someone only uses ip address in web browsers?

I want to disable access to website when someone uses http://123.1.1.1 or https://123.1.1.1, but same time it should be accessible via fqdn.

user-image
Question added by NAFI RAHMAN KATTIL PUTHIYA PURA , IT Support Engineer , Cleveland Clinic Abu Dhabi
Date Posted: 2014/01/31
Deleted user
by Deleted user

If you use apache virtual host you can set default virtual host simply by entry:

<VirtualHost *>

DocumentRoot /default_dir

</VirtualHost>

and without ServerAlias or ServerName, then you should setup second virtual host with domain name

<VirtualHost *>

ServerAdmin

DocumentRoot /home/dir

ServerName www.example.com

</VirtualHost>

so with that configuration if server get IP it should point to default directory but with domain in heders it sould point to this domain directory.

Satyaveer Arya
by Satyaveer Arya , System Engineer , InterGlobe Technologies

To set-up visitors restrictions and blocking, create a .htaccess file following the main instructions and guidance which includes the following text example:

 

order allow,deny

deny from 255.0.0.0

deny from 123.45.6.

allow from all

kalaiarasan V
by kalaiarasan V , System Analyst , Syntel

Just add the Ip address Instead of website address in "ServerName" paremeter at httpd.conf file

Deleted user
by Deleted user

by using the module authz_host (RequireAll, RequireAny, RequireNone)

Require not ip X.X.X.X 

Muhammad Anzar
by Muhammad Anzar , DevOps/DevSecOps Architect , Confidential

You can restrict following ways for IP Based browsing. Normally you will point fqdn with directory pat

 

a) First option using limit 

 

<Limit GET POST PUT> order deny,allow deny from all allow from192.168. deny from104.113. </Limit>

 

b) Restrict virtual directory path

 

<Location /jobs> Order deny,allow deny from all allow from192.168. allow from104.113. </Location> <Location /apples> Order deny,allow deny from all allow from192.168. allow from104.113. </Location>

 

 

 

Deleted user
by Deleted user

You can do this using the .htaccess file. Just create one and paste in it the following lines and change the IP address to your server's:

 

RewriteEngine onRewriteCond %{HTTP_HOST} ^123.1.1.1$RewriteRule ^(.*)$ - [F,L]

 

عبدالرزاق رحمون
by عبدالرزاق رحمون , IT engineer , Ministry of Education

in .htaccess write

Order Deny,Allow

Deny from 123.1.1.1

for more info http://www.htaccesstools.com/block-ips/

More Questions Like This