Search code examples
.htaccesshttp-redirectmod-rewriteurl-rewriting

Htacces: generate 404 error for a partially path


I was attacked on my website and redirects to malicious sites were generated. I already cleaned everything but I keep showing up in the Google SERP and to disappear I have to generate 404 errors for the affected routes. So says Google that it is the first step to disappear from the search. Now the links that appear from the Google SERP already direct to my website but I want them to generate 404.

All links are like this:

http://misitioweb.com/?bezstywue=un-monton-de-parametros1

http://misitioweb.com/?bezstywue=un-monton-de-parametros2

http://misitioweb.com/?bezstywue=un-monton-de-parametros3

I want to make everything that starts with

http://misitioweb.com/?bezstywue

generate 404 error

I´ve tried scripts like

RedirectMatch 404 ^\?bezstywue(.*)$

But dont works Could you help me? Thanks


Solution

  • You will need to check the query string to do this. You could try something like this:

    RewriteCond %{QUERY_STRING} ^bezstywue
    RewriteRule (.*) - [R=404,L]