Home > OS >  blocking website pages starting with numbers
blocking website pages starting with numbers

Time:03-11

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.

CodePudding user response:

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.)

  • Related