Search code examples
.htaccessquery-string

Can you filter/inspect POST method/requests with htaccess?


Can you filter/inspect POST method/requests with htaccess For example, if you want to filter a $_GET variable with htaccess to redirect if a pattern is matched, it would look like this:

RewriteCond %{QUERY_STRING} <script> [NC]
RewriteRule .*$ /mylogPage.php? [L,R=301]

Can you do a similar filter for $_POST variables?

I have tried many variations including an attempt to modify mod_security through htaccess. I assume in htaccess it will have something to do with:

RewriteCond %{REQUEST_METHOD} POST.

I have tried

RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} <script> [NC]
RewriteRule .*$ /mylogPage.php? [L,R=301]

But it only redirected the page

If this should be done through mod_security, can one edit mod security through htaccess? What would the syntax look like? I have tried but was not successful.


Solution

  • I have done research and spoke to my hosting company as well. If you are on shared hosting, all domains on the same server share the same settings for mod_security,so it is not possible to access and/or edit mod_security through htaccess. If that was possible, you would modify mod_security to affect all website on the server. On shared hosting it is only possible to inspect $_GET variables through htaccess.