Question

I was asked by a friend to fix a wordpress website with a bb press forum that was over-run by spammers. The wordpress site was okay, but the bb forum had over 1,500 urls of spammed entries in the space of about 3 months. The site is hosted by Godaddy and the person who was managing it was instructed by them to delete all content. They did this and now the webmaster tools is showing 1,500 404 errors. I have since deleted and reinstalled plugins on site and locked down wordpress to not allow subscribers or comments. Spam visits have diminished tremendously. But the damage is still there.

I have read extensively about creating 410 Gone command for search engines on those now deleted spammed posts. No where can I find sample code and instructions on where to insert the code appropriately. I have access to ftp and know how to open .htaccess in text edit. I also know where to find php files and how to get access to them. But I only know enough about php to get myself into a lot of trouble.

I found a site that offers .htaccess code sample. So I have attempted to plug in my data and am just looking for a 'spot check' from someone who knows the code.

I am keeping everything in the domain as is but need to redirect the subfolder http://www.mydomain.com/forums/ and everything in it to display a 410, meaning that all content is permanently gone inside that /forums/ folder and search engine no longer should look for it.

Here is the sample .htaccess file code I found:

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule (.*) http://www.ourdomain.com/$1 [R=301,L]
#
# Folder that exists no more
RewriteRule ^forums/discontinued\.html$ - [G]
#
Redirect 301 /folder/index.html http://www.ourdomain.com/forums/
#
# File that exists no more
Redirect gone [b]/f[/b]ilea.html

Is this the proper code to place inside the .htaccess file on my wordpress site to eliminate searches on the now deleted /forums/ folder and all content that was ever posted in it?

I appreciate all help on this.

Also, where can I get a tutorial on how to write .htaccess code online, for future reference.

Thank you very much for the help. I am grateful.

Was it helpful?

Solution

All you need to do is something like this:

RewriteEngine On
RewriteCond %{REQUEST_URI} /forums/(.*)
RewriteRule (.*) http://www.example.com/forums/$1 [R=410,L]

That will catch anything that starts with http://www.example.com/forums and redirect it to a 410.

Also note, if you are modifying an existing .htaccess, it likely already has the RewriteEngine On line somewhere near the top (usually the first non-comment line), so you don't need to have it twice. Just the RewriteRule added somewhere should work. If there are lots of other RewriteRules, you should probably put it near the top. If there are just a few default lines from Wordpress, below those should suffice.

OTHER TIPS

This could also be done by using the following, single rule:

RewriteRule ^/forums(/.*)?$ - [G,NC]

This will 410 all the following URLs:

http://www.example.com/forums
http://www.example.com/forums/
http://www.example.com/forums/my-forum-post-1
http://www.example.com/forums/my-forum-post-2/

The [G] flag denotes the 410 Gone status, the [NC] flag makes the URLs case-insensitive, and the [L] isn't needed since it's implied with the [G] flag.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top