Search code examples
.htaccessfilter

.htaccess, can I block all requests starting with exactly "/index.php?action="


Is there a .htacces way to block all request starting with exactly /index.php?action=?

I figured out:

RewriteCond %{QUERY_STRING} \baction=\b [NC]
RewriteRule ^ - [F]

But how do I put the part /index.php? in front of that pattern. I tried a lot, but it didn't work and only this part of the pattern also blocks &action= parameters somewhere else in a URL

Hope you can help. Many thanks in advance, Nico


Solution

  • You can use THE_REQUEST variable to match full URL and block it like this:

    RewriteCond %{THE_REQUEST} /index\.php\?action= [NC]
    RewriteRule ^ - [F]