Many friends ask me to limit only certain ip are allow to access their website. To limit specific ip to access website is easy with .htaccess. Just follow the steps below and you will be able to set your website to be view by specific ip:-
Advertisements
- Create a file and name it .htaccess with the content below:-
order deny,allow deny from all allow from 888.888.888.888
Please change 888.888.888.888 to the ip you want to allow.
- Once the file is created, put it at your root directory. (This will be in http://www.yourdomain.com/.htaccess)
- Done! Now your website is can only be access by the ip you set!
- If you want to allow multiple ip address to access your website, just create another record of ip like below:-
order deny,allow deny from all allow from 888.888.888.888 allow from 999.999.999.999 allow from 000.000.000.000
[tags].htaccess, limit ip access, htaccess limit ip access, limit ip access website[/tags]
Related posts:
Prestashop 1.5 - How to enable add to cart button at Home Featured Product?
Mod Security - Open source Web Application Firewall
Namecheap Coupon 2007 - April
Password protect directory with .htaccess and .htpasswd
Speed Up and Save Your Website Bandwidth with GZip Compression
Bootstrap - The Responsive Framework
Install eAccelerator to Optimize PHP performance
How to add social bookmark link to your Blogger.com blog
Share this with your friends:-
I do not have a static IP at home, so I am unable to use my IP address for access. However I do use a DDNS service to remote in to my home.
How do I incorporate my DDNS address for access.
example
myhome.ddnsserver.com does ping back to my home IP.
How can I specify to allow myhome.ddnsserver.com access?
thanks
@Haydon – you can have a separate .htaccess for each directory, so you can allow or limit access to each directory individually.
Thanks for very useful tricks. I will only allow my own IP in admin area, I hope this code will do it.
Edit httpd.conf
#vi /etc/httpd/conf/httpd.conf
Look for htaccess
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be “Allâ€, “Noneâ€, or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Order allow,deny
deny from 192.168.100.0/24
deny from 192.168.101.0/26
allow from all
FYI: This will deny hosts with IP’s from 192.168.100.0/24 & 192.168.101.0/26…
It works! (“,)
Edit httpd.conf
#vi /etc/httpd/conf/httpd.conf
Look for htaccess
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be “All”, “None”, or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Order deny,allow
deny from all
allow from 192.168.100.0/24
allow from 192.168.101.0/26
FYI: This will allow only hosts with IP’s from 192.168.100.0/24 & 192.168.101.0/26…
It works! (“,)
hmmm from wat i know, u can only block a range but not in the same range.
anyone know the tricks?
thanks this gives me a headstart. what i want to do is to give access only for a range of ip address (like from 50 to 100 only) what should i do then?
thank you for this…
Haydon,
In case you haven’t gotten your answer yet….. just put the .htaccess file in any folder you need to protect. I believe it will work recursively, any file or folder contained within the folder with the .htaccess will follow the same rules.
Hope this helps.
Very useful – thanks. How would you limit certain ip to certain folders? I don’t want to limit access to the whole site, just certain folders.