httpd Deflector Maps
I'm trying to set up deflector maps in httpd.conf to reroute bots based on agent and IP address. I entered the following code (Pre Main Include - all versions) in the Service Configuration " Apache Configuration " Include Editor:
RewriteEngine on
RewriteMap deflector txt:/home/user/maps/deflector_agent.map
RewriteCond %{HTTP_REFERER} !=""
RewriteCond ${deflector:%{HTTP_REFERER}} =-
RewriteRule ^ %{HTTP_REFERER} [R,L]
RewriteCond %{HTTP_REFERER} !=""
RewriteCond ${deflector:%{HTTP_REFERER}|NOT-FOUND} !=NOT-FOUND
RewriteRule ^ ${deflector:%{HTTP_REFERER}} [R,L]
RewriteEngine on
RewriteMap ip-deny txt:/home/user/maps/deflector_ip.map
RewriteCond ${ip-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND
RewriteRule ^ - [F]
However, this doesn't seem to be working. I entered my IP in the deflector_ip.map file but I'm not blocked from my site. What am I doing wrong?
Thanks,
Frank
-
Hello Frank, You may want to add the entries as a virtual host include for all virtual hosts instead of a "Pre Main Include". Here's a thread where this is discussed (it's for different entries but the same principal applies): Thank you. 0 -
Thanks, Michael. I tried both Pre VirtualHost Include and Post VirtualHost Include, but neither of those worked for me either. Is it because I'm using LiteSpeed instead of Apache? Or do I need more code to get what I've written to be recognized? The code I posted should work, as I copied it almost verbatim from the Apache website. I usually add these things to .htaccess, however this particular solution won't work there and is required to go in httpd.conf. 0 -
For the life of me, I still can't figure this out. Does anyone have an example of how to set up a deflector map on httpd? There are plenty of examples on how to create the map, but absolutely nothing on how to set up RewriteMap in the conf file. Thanks. 0
Please sign in to leave a comment.
Comments
4 comments