[How to] Blocking visitors with certain IPs from accessing your website with .htaccess

Started by Xhanch Studio, September 29, 2011, 11:21:21 AM

previous topic - next topic
Go Down

Xhanch Studio

If your server's load is unusually high. You may want to check your raw access logs.
You may find suspicious IPs that seems to brute force / overwhelm / attack your site.
If you find it, just block those IPs and you will save / reduce your server's load greatly.

In your .htaccess file, you can add the following codes somewhere (changing the IPs to suit your needs. Each command on one line each):
Code Select
order allow,deny
deny from 1.2.3.4
deny from 2.3.4.
allow from all


You can deny access based upon IP address or an IP block. The above blocks access to the site from 1.2.3.4, and from any sub domain under the IP block 2.3.4. (2.3.4.1, 2.3.4.2, 2.3.4.3, etc.) I have yet to find a useful application of this, maybe if there is a site scraping your content you can block them, who knows.

You can also set an option for deny from all, which would of course deny everyone. You can also allow or deny by domain name rather than IP address (allow from .xhanch.com works for www.xhanch.com or xxx.xhanch.com, and so on)
Best Regards,
Susanto B.Sc
----------------------------------------------------------------------------
Web development services, WordPress plugin and theme development, PSD to XHTML conversion - http://xhanch.com
Read free manga online - http://authrone.com

Go Up