Rant: Don’t use “301 Moved Permanently” where “404 Not Found” or “410 Gone” should be used
Are you a web developer? Does your website redirect all links that cannot be found (either because they are misspelled or the url got removed) to your main page? This article is for you.
Since you are apparently too stupid too read, lets go through the standard very slowly, so even you can understand it:
The MDN documentation about 301 says:
The HyperText Transfer Protocol (HTTP) 301 Moved Permanently redirect status response code indicates that the requested resource has been definitively moved to the URL given by the Location headers.
So only use 301 if the URL given by the location header actually does contain the same content that the original URL used to contain. If the location header is your main page, this is wrong, the page was not moved to the main page. Instead you should use 404 Not Found or 410 Gone. That way any link-checker can properly see that a broken link is indeed a broken link.
I don’t know why you do this, but it’s probably because some SEO-fuckface told you that it gives you an advantages over honest sites.
I hope you die a painful death.