Home > How To's/Reviews > 410 Entire Directory With .htaccess

410 Entire Directory With .htaccess

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.


My posts are not to serve as a replacement for recommendations provided by licensed physicians nor do they represent the opinions of Baylor College of Medicine or its affiliated institutions. Please read this site's Disclaimer and Terms of Use for more information.


WordPress PHP Shortcodes For Yearly Post And Comment Counts

I wanted an easy way to calculate some end-of-year stats, so I put together a …


Your email address will not be published. Required fields are marked *