Block IP Addresses using Map File
2 posts
• Page 1 of 1
Block IP Addresses using Map File
I'm trying to create a map file with a list of ip address I would like to block.
mapfileBlockedIPs.txt contains one line which is my ip address.
162\.40\.252\.25
I have written a rule to use this list of ip's and return a Forbidden if matched.
RewriteMap mapfileBlockedIPs txt:D:\DLLs\ISAPI\mapfileBlockedIPs.txt
RewriteCond %{REMOTE_ADDR} (.*)
RewriteCond ${mapfileBlockedIPs:${%1}|NOT_FOUND} !NOT_FOUND
RewriteRule (.*) - [F]
For some reason this never matches and does not block my ip.
When I try the rule without a map file the match does occur and my ip is blocked.
RewriteCond %{REMOTE_ADDR} 162\.40\.252\.25
RewriteRule (.*) - [F]
What am I doing wrong?
mapfileBlockedIPs.txt contains one line which is my ip address.
162\.40\.252\.25
I have written a rule to use this list of ip's and return a Forbidden if matched.
RewriteMap mapfileBlockedIPs txt:D:\DLLs\ISAPI\mapfileBlockedIPs.txt
RewriteCond %{REMOTE_ADDR} (.*)
RewriteCond ${mapfileBlockedIPs:${%1}|NOT_FOUND} !NOT_FOUND
RewriteRule (.*) - [F]
For some reason this never matches and does not block my ip.
When I try the rule without a map file the match does occur and my ip is blocked.
RewriteCond %{REMOTE_ADDR} 162\.40\.252\.25
RewriteRule (.*) - [F]
What am I doing wrong?
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Block IP Addresses using Map File
Hello,
Firstly make you mapfile look like:
and edit your rule as in following:
RewriteMap mapfileBlockedIPs txt:D:\DLLs\ISAPI\mapfileBlockedIPs.txt
Regards
Andrew
Firstly make you mapfile look like:
- Code: Select all
162.40.252.25 162.40.252.25
and edit your rule as in following:
RewriteMap mapfileBlockedIPs txt:D:\DLLs\ISAPI\mapfileBlockedIPs.txt
- Code: Select all
RewriteCond %{REMOTE_ADDR} (.*)
RewriteCond ${mapfileBlockedIPs:%1|NOT_FOUND} !NOT_FOUND
RewriteRule (.*) - [F]
Regards
Andrew
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 3 guests