I'm setting up a server for a school project, and want to block POST requests from origins outside my domain and its subdomains.
I tried to neglect the localhost IP, the page from which the POST comes and the subdomain, but none worked (a 403 access denied error is always thrown).
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} !/api/auth.php #listing allowed origins
RewriteCond %{REQUEST_URI} !/auth.php
RewriteCond %{REMOTE_ADDR} !127.0.0.1
RewriteCond %{REMOTE_HOST} !domain.com
RewriteCond %{REMOTE_HOST} !api.domain.com
RewriteCond %{REMOTE_HOST} !www.domain.com
RewriteCond %{REMOTE_HOST} !^(.*)\.domain\.com
RewriteRule .* - [F,L]
</IfModule>
I expect when posting from a URL outside domain.com
the request to be blocked with a 403 error, but the actual result is I'm receiving a 403 error also from within domain.com