Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I block POST requests to urls ending with /trackback/ in .htaccess?

I'm wanting to block POST requests to a specific URL on a website. Here is an example of a spammy POST request from my Apache log:

110.86.178.xxx - - [14/Jan/2015:17:05:05 +0000] "POST /profile/example/trackback/ HTTP/1.1" 200 85 "http://example.com/profile/example/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) )"

I added the following code to the .htaccess file:

# deny POST requests
<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_METHOD} POST
    RewriteRule /profile/example/trackback/ [F,L]
</IfModule>

Unfortunately I'm still receiving trackback emails, so it's not working.

What is the issue and how can I fix this? Also, how could I amend the code to block all POST requests sent to urls ending in /trackback/

Thanks!

like image 908
iagdotme Avatar asked Sep 30 '22 00:09

iagdotme


1 Answers

You can use this rule in root .htaccess:

RewriteEngine On

RewriteCond %{REQUEST_METHOD} POST
RewriteRule (^|/)trackback/?$ - [F,NC]
like image 115
anubhava Avatar answered Oct 04 '22 22:10

anubhava