.htaccess restrict access to site via IP address

dagan

New Member
#1
I want to restrict users from being able to access my website via the servers own IP. I understand this can be done through Htaccess, but is there another way through the OLS admin panel through maybe virtual hosts etc? I am new sorry, but I figured there may be. Thanks for your time!
 

lskagan

Administrator
#2
Under Virtual Host -> Security there is access control where you can add IPs to Allow/Deny. This should achieve what you are looking to do.
 

dagan

New Member
#3
... To be clear I want to restrict access through IP address of the server. So no one can visit the site via 99.99.99.99/index.php - It would give them an error saying no access via IP or redirect etc.
 

lskagan

Administrator
#4
My misunderstanding dagan, as long as you do not have a * or the IP set for your listeners -> virtual host mappings -> Domains it should only allow access via the domain itself and show 404 pages for the rest.
 
#5
Hi sorry for the late reply, so what should it be set as? Currently it's set as ANY... Should I be setting it as 127.0.0.1 or the actual server ip?
 
#7
It displays 404 now, however if the IP is typed with httpS then it comes through still.

I'm added this:
# rewrite directaccess
Options +FollowSymLinks -MultiViews
RewriteEngine on

RewriteCond %{HTTP_HOST} ^my.i.p.address$ [NC]
RewriteRule ^$ http://www.google.com/ [R=301,L]

but this only works for the ip address alone, if you access via https://my.i.p.address/page it will still work and allow access
 
Top