Apr

13

Block IPs Using htaccess

April 13, 2008 |

How do I block certain IPs from accessing my site or directory? It’s pretty easy! All you have to do is create an .htaccess file in the directory you’d like to restrict (your main directory to restrict the entire site) and then put the following in it:
order allow,deny
allow from all
deny from 123.142.124.152
deny from 124.24.


You can put whole ips or just the beginning part you’d like to match, and you can add more and more ips, each with its own line!

When somebody’s ip is banned, they will get a 403 error (access forbidden) when trying to visit your site.



Similar Posts

Comments

Name (required)

Email (required)

Website

Speak your mind

1 Comment so far

  1. Block people from Certain URL Using htaccess | Highub - Web Development Blog on April 14, 2008 10:25 am

    [...] actually very similar to blocking people by IP! Again, you need to add some lines to an .htaccess text file that you create in the home directory [...]

Sponsors




Links