'How do I 410 a pattern of toxic Prestashop URLS?

I've been trying to 410 a pattern of a few thousands toxics URLS that got indexed by Google for one of my clients. I want every urls of the website that contain ?% to send a 410 response code so they got de-indexed.

Example of an URL :

https://www.example.com/fr/promotions?%25252525253Bid_lang=6&p=6

I've tried to put this in the .htaccess, above the If module section, as I found on another thread here, but it didn't work, any ideas ?

RewriteRule ^[a-z]shop($|/) - [G]


Solution 1:[1]

I want every urls of the website that contain ?% to send a 410 response code

Using mod_rewrite at the top of the .htaccess file:

# Send 410 for any URL where the query string starts with "%"
RewriteCond %{QUERY_STRING} ^%
RewriteRule ^ - [G]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1