Search code examples
regex.htaccessquery-stringblocking

I want to block an url with htaccess and <FilesMatch> with quest mark (not query string)


I found a lot of topics about blocking query string url via .htaccess on stackoverflow. But I need to block a bunch of not existing urls :like http://www.vvdealblas.nl/?/member/login (urls from the old cms).

I want to do this with FilesMatch, something like:

<FilesMatch "^{regex}$">
    Order deny,allow
    Deny from all
</FilesMatch>

Thanks!


Solution

  • You cannot do that via FilesMatch since you want to match QUERY_STRING. Use mod_rewrite instead:

    RewriteEngine On
    
    RewriteCond %{QUERY_STRING} ^/member/login$ [NC]
    RewriteRule ^/?$ - [F]