Brian
Brian

Reputation: 31

How to block POST requests to a specific URL or text in the Apache access log

For Example here is the record in the Apache Log that I want to block:

75.130.202.149 - - [11/Dec/2015:11:00:01 -0500] "POST /blog/insert_data HTTP/1.1" 302 20 "http://brokerasheville.com/blog/view/broker-asheville-sponsors-the-20th-annual-montford-holiday-tour-of-homes" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36"

I want to block anything that has /blog/ in it.

This is what I have in my .htaccess file:

RewriteEngine On

RewriteCond %{REQUEST_METHOD} POST
RewriteRule (^|/)blog/?$ - [F,L]

What am I missing as this won't stop a spam bot from posting to my blogs.

Thanks!

Upvotes: 3

Views: 4832

Answers (1)

anubhava
anubhava

Reputation: 785641

Try this rule as your very first rule:

RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{THE_REQUEST} /blog[/?\s] [NC]
RewriteRule ^ - [F,L]

Upvotes: 3

Related Questions