SEO Professional Saboor asked John Mueller on Twitter about 404 errors and SEO spam.
Their situation:
Their website was affected by SEO spam. Their server had multiple malicious files added to it. The website normally has 50 pages total. Now, Google has indexed approximately 1500 of them.
The malicious files have been deleted and 301 redirects are setup to the homepage for 404s.
Their question is: What is the right way to index these pre-existing pages?
John said you don’t really have to do anything special. These will drop out of the index over time.
If you do want to do something, he says he would check Search Console for the URLs that got the most impressions, and request removal for them manually.
You don't really need to do anything special – they'll drop out of the index over time. If you do want to do something, I'd check Search Console for the URLs that got the most impressions, and request removal for them manually.
— 🐝 johnmu.xml (personal) 🐝 (@JohnMu) June 2, 2022