If Google has penalized your domain name because of your link building spree, then you can very easily get rid of Penalty by forcing 404 or 410 HTTP headers.
What are 404 and 410 HTTP Status Codes?
- 404 (commonly known as Not Found Error Page): It means that the requested page can’t be found at this time, but may become available in near future. A 404 page also allows subsequent requests by clients (users and search engine bots).
- 410: It means that the requested page has been deleted permanently and will not be available again in near future. A 410 Page doesn’t allow subsequent request by clients and search engines are forced to purge the page completely.
Note: Before proceeding further, keep in mind that this trick will only work if your domain has been penalized because of incoming bad links that points to a sub-directory / sub-page (E.g. http://yourdomain.com/abc/xyz/ etc.) or a sub-domain (E.g. http://abc.yourdomain.com/ and its sub-page). If you have been penalized because of links that points to your Homepage, then you simply can’t force above errors on it!
Update: Now Google treats both 404 and 410 HTTP Headers SAME!
How to return 404 HTTP Header?
Almost all CMS as well as your web server (Apache, Lite Speed etc.) returns 404 HTTP header when a requested page can’t be found.
In order to get rid of penalty, simply delete the sub-page that is responsible for penalizing your website, and you should see a not found error page either generated by your CMS or by your Web Server:
You can also customize these 404 pages either directly from your CMS or by using .htaccess. Open your .htaccess file and place following line of code in it:
ErrorDocument 404 /404.html
Now create a new HTML page with name 404.html (you can add some fancy text and images in it) and place it in the root directory of your domain name. Whenever a user or search engine bot lands on deleted sub-page(s), your server will serve 404 HTTP header, along with the HTML page you just created.
Note: You are only required to create a 404 error document in .htaccess, if your server is serving an error shown in screenshot above. If you are using a CMS, then you need to gather information about how to customize 404 not found error pages in it.
How to return 410 HTTP Header?
A 404 HTTP header will remove any penalty placed on your site, but if you’d like to return a 410 status code instead, then you can use following PHP code and upload the file to the URL (after deleting or moving its content) that’s responsible for penalizing your website:
header(“HTTP/1.0 410 Gone”);
You can also include some HTML code OR your website’s template with above, so that your server doesn’t return a blank page in web browser. Returning 410 HTTP header using a CMS is a bit complicated process, as you may have to edit core configuration files.
Important Note: Never ever 301 redirect penalized sub-pages to Homepage or some other page after deleting them. If you do so, you will pass the penalty to the redirected page.