4

一位朋友要求我修复一个带有 bb 新闻论坛的 wordpress 网站,该论坛被垃圾邮件发送者占据。wordpress 网站还可以,但 bb 论坛在大约 3 个月的时间里有超过 1,500 个垃圾邮件条目的 url。该网站由 Godaddy 托管,管理该网站的人被指示删除所有内容。他们这样做了,现在网站管理员工具显示 1,500 404 错误。此后,我在网站上删除并重新安装了插件,并锁定了 wordpress,不允许订阅者或评论。垃圾邮件访问量大大减少。但伤害仍然存在。

我已经广泛阅读了有关在那些现已删除的垃圾邮件帖子上为搜索引擎创建 410 Gone 命令的内容。我在哪里可以找到示例代码和有关在何处适当插入代码的说明。我可以访问 ftp 并且知道如何.htaccess在文本编辑中打开。我也知道在哪里可以找到 php 文件以及如何访问它们。但我对 php 的了解还不足以让自己陷入很多麻烦。

我找到了一个提供.htaccess代码示例的网站。所以我试图插入我的数据,只是在寻找知道代码的人的“抽查”。

我将域中的所有内容保持原样,但需要重定向子文件夹http://www.mydomain.com/forums/以及其中的所有内容以显示 410,这意味着所有内容都永久地消失在该 /forums/ 文件夹中并且搜索引擎不再应该寻找它。

这是我找到的示例.htaccess文件代码:

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

这是放置在 .htaccess 文件中的正确代码/forums/吗?

我感谢所有帮助。

另外,我在哪里可以获得有关如何.htaccess在线编写代码的教程,以供将来参考。

非常感谢你的帮助。我很感激。

4

2 回答 2

2

这也可以通过使用以下单一规则来完成:

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

这将 410 以下所有 URL:

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/

[G]标志表示410 Gone状态,该[NC]标志使 URL 不区分大小写,并且[L]不需要,因为它暗示了[G]标志。

于 2014-05-22T17:54:29.933 回答
2

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.

于 2014-01-29T22:02:15.017 回答