[solution] Block external POST to my domain

By.

min read

My profile

Share this:

Here we go… the solution is a simple as it gets ( using htaccess )

It is in fact a tweaked hotlinking script except we don’t care if its an image, but we DO care if its a PUT or a POST 🙂

Please adjust [b:8f2712e42d]mydomain.com[/b:8f2712e42d] to your own domain !
To test: just leave mydomain.com and hit SUBMIT on a POST method form at your site!

[code:1:8f2712e42d]RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(PUT|POST)$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+.)?mydomain.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule ^(.*)$ http://127.0.0.1 [L][/code:1:8f2712e42d]

ps: requests are redirected to 127.0.0.1 which is localhost.
ps2: this method may not work on all webhosts !

Share this:

Leave a Reply

Your email address will not be published. Required fields are marked *