|
Home » Other Tips » .htaccess » Deny Users by IP Address Deny users by IP addressOccassionally a site will receive visits from a bad source. This could be someone trying to hack your server or just somebody (or a robot) taking up too many of your resources. .htaccess allows us to secure against this by allowing or denying visitors by their IP address. Let's look at the following code. Order deny, allow The first line tells Apache to deny first, then allow. The second line blocks any visitor from IP address 123.123.123.123. The third line blocks anyone with an IP starting with 234 - so 234.123.123.123 would be blocked. The last line tells Apache to allow anyone that doesn't match the deny lines in. The example above would be used when you want to deny a few specific addresses. What happens if you only want to allow a few? Order allow, deny Let's say you are on IP address 123.123.123.123 and while developing your site you don't want anyone else to be able to view it. The code above will block everybody else with a 403 Forbidden error. You will be able to get through. |
