410 Entire Directory With .htaccess

1

Due to an oversight with folder permissions, I was recently the victim of a massive spam attack. I fixed the problem by issuing a 410 redirect to all links pointing to a particular folder in my file tree.

If you’re trying to force a 410 (“gone”) status code for a particular folder directly in your site’s root path (ie, /public_html/someFolder), place the following in your root .htaccess file.

RewriteEngine On
RewriteBase /
RewriteRule ^someFolder/ - [G]

Replace “someFolder” with the folder of interest. For example, if you’re trying to 410 redirect /public_html/blog, use “blog” in the code above. Then test the site by opening a browser and navigating to the folder you blocked. You should be prompted with a “Gone” error page for any page under that folder (ie, http://yourdomain.com/someFolder/, http://yourdomain.com/someFolder/page1, http://yourdomain.com/someFolder/page2, etc.)

The 410 HTTP status code basically means that a page is “gone” and should never come back. This should hopefully let major search engines index everything accordingly.

 1 COMMENT

 LEAVE A REPLY

Please enter your comment!
Please enter your name here