Rewrite Map Question

Helicon Ape provides support for Apache .htacces and .htpasswd configuration files for Microsoft IIS.
User avatar
Posts: 6
Joined: 01 Nov 2013, 02:21

Rewrite Map Question

30 Oct 2018, 00:19

Hi,

Can you rewrite map be used to create a list of bad IP addresses to block/send to 403?

This works for a single IP:

RewriteCond %{HTTP_Host} ^(?:www\.)?(.+)
RewriteCond %{REMOTE_ADDR} ^XXX.XXX.XXX.XXX$
RewriteRule ^(.*)$ - [R=403,L]

Rather than creating 20K lines of RewriteCond for each IP address; I tried using a rewritemap but I can't get it working.

I tried using the following with no success:

RewriteMap blockediplist txt:C:\directory\blockediplist.txt
RewriteCond %{HTTP_Host} ^(?:www\.)?(.+)
RewriteCond %{REMOTE_ADDR} ^{blockediplist:%1}$
RewriteRule ^(.*)$ - [R=403,L]

The blockediplist.txt includes IP addresses one per line.

Any help would be appreciated.

Thanks,
Pat

User avatar
Posts: 92
Joined: 01 Dec 2012, 14:22

Re: Rewrite Map Question

15 Apr 2019, 20:56

My understanding of RewriteMap is that it's a key-value pair. A simple list of IPs won't suffice, you need to return some sort of value, and then do something with it.

123.123.123.123 403
So if your key were 123.123.123.123, the return value would be 403

Return to Helicon Ape

Who is online

Users browsing this forum: No registered users and 8 guests