Register now or log in to join your professional community.
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.
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.
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
Just add the Ip address Instead of website address in "ServerName" paremeter at httpd.conf file
by using the module authz_host (RequireAll, RequireAny, RequireNone)
Require not ip X.X.X.X
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>
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]
in .htaccess write
Order Deny,Allow
Deny from 123.1.1.1
for more info http://www.htaccesstools.com/block-ips/