Score:0

How to block all requests starting with "?mode" on Apache?

ms flag

Recently my website was hacked and now I have around 20000 indexed links in Google that were redirected to other sites via my website. Now I have stopped all redirects but I have too many request on my host. All indexed links in Google are something like this:

  • example.com/?mode=list1124413.html

  • example.com/?mode=grid125761916.html

I want to block all requests starting with ?mode but I don't know why these configurations I have tried are not working:

RewriteCond     %{QUERY_STRING} ".*(?:^|&)mode=(?:=|&|$)"
RewriteRule     "" "-" [F]

RedirectMatch 404 ^?mode/\d+$
RedirectMatch 404 ^mode\d+$
Score:0
jp flag

It is not possible to match query strings with mod_alias:

mod_alias is designed to handle simple URL manipulation tasks. For more complicated tasks such as manipulating the query string, use the tools provided by mod_rewrite.

A working configuration with mod_rewrite:

RewriteEngine  On
RewriteCond    %{QUERY_STRING} "(^|&)mode="
RewriteRule    "" "-" [F]
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.