PSZ_Code
PSZ_Code

Reputation: 1045

Blocking ip with htaccess

I have a htaccess file with following code when trying to block an IP:

DirectoryIndex index.php index.html

ErrorDocument 404 /errors.php

Order Allow,Deny
Deny from 188.143.232.
Allow from all

Blocking my own IP works when browsing www.example.com, but it does not block for anything else (like www.example.com/index.php or www.example.com/home, ....). The htaccess is located in the same directory as index.php (httpdocs folder).

How can I get it to work?

Upvotes: 0

Views: 506

Answers (1)

Amit Verma
Amit Verma

Reputation: 41209

You can also use a mod-rewrite based ip-blocking to block unwanted ip(s) :

RewriteEngine on

#--if client ip==188.143.232
RewriteCond %{REMOTE_ADDR} ^188\.143\.232
#--forbid the request
RewriteRule ^ - [F,L]

Upvotes: 2

Related Questions