'blocking website pages starting with numbers

My website has probably been hacked with a conditional redirect. It shows Japanese language in the search result. I have shown a sample link below.

https://example.com/11449tkbhb6bvkb1f

All the links start with a number as mentioned above.

I have already replaced the code with the backup of the website. However, I want to block all the urls that starts with the number using htaccess. Please suggest.



Solution 1:[1]

Presumably these requests already serve a "404 Not Found" response? (If not then this needs to be resolved. Either these URLs resulted because of a "hack" or because of an error with your app that allowed these URLs to be indexed in the first place.)

However, you can send a "410 Gone" response to help speed up the process of search engines dropping the URLs from the search results.

For example, at the top of the root .htaccess file using mod_rewrite:

RewriteEngine On

# Send a 410 for any requests that start with a number
RewriteRule ^\d+ - [G]

This will serve a "410 Gone" for any request that "starts with a number".

(You do not need to repeat the RewriteEngine directive if this is already present in the file.)

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