Rewrite Map Question
2 posts
• Page 1 of 1
Rewrite Map Question
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
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
Re: Rewrite Map Question
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
123.123.123.123 403
So if your key were 123.123.123.123, the return value would be 403
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 5 guests