.htaccess 如何使用htaccess解决这些vbulletin 404错误?

.htaccess 如何使用htaccess解决这些vbulletin 404错误?,.htaccess,mod-rewrite,http-status-code-404,vbulletin,.htaccess,Mod Rewrite,Http Status Code 404,Vbulletin,我有一个非常大的论坛(230k个线程,300万个帖子),在谷歌网站管理员工具上有大量404个页面,大约14000个404个URL。谷歌展示这些404可能是因为我有到它们的链接,这意味着我失去了很多SEO的好处,因为没有这些链接到实际的页面 我知道我为什么会有这个问题,一年前我网站上的URL被改回vBulletin默认值,所以它们看起来像这样: http://www.domain.com/showthread.php?t=323653&p=4230256 我想让他们保持这样,因为他们已经

我有一个非常大的论坛(230k个线程,300万个帖子),在谷歌网站管理员工具上有大量404个页面,大约14000个404个URL。谷歌展示这些404可能是因为我有到它们的链接,这意味着我失去了很多SEO的好处,因为没有这些链接到实际的页面

我知道我为什么会有这个问题,一年前我网站上的URL被改回vBulletin默认值,所以它们看起来像这样:

http://www.domain.com/showthread.php?t=323653&p=4230256
我想让他们保持这样,因为他们已经这样一年了。问题是之前有两种格式显示404错误:

这些:

http://www.domain.com/forums/showthread.php?t=21461

http://www.domain.com/forums/showthread.php?t=16187
只需从URL中删除
论坛/
,以及以下内容:

http://www.domain.com/forums/f8/39840-infractions_system_how_works.html

http://www.domain.com/forums/f11/67410-viewing_ijji_gunz_replays_while_offline.html
这是我安装vbSEO时创建的一个时髦的URL结构


/forums/
需要删除,我认为39840和67410可能是线程id。我认为URL中有我们需要重写的所有内容,但我不完全确定如何使用htaccess实现它。

假设您的
.htaccess
位于网站根“/”


通过
httpd.conf
启用mod_rewrite和.htaccess,然后将此代码放入
文档根目录下的
.htaccess

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

# to redirect /forums/f8/39840-something.html to
# /showthread.php?t=39840
RewriteRule ^forums/[^/]+/([^-]+)-[^.]+\.html$ /showthread.php?t=$1 [R=301,NC,L,QSA]

# to redirect /forums//showthread.php?t=39840 to
# /showthread.php?t=39840
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^forums/([^/]+)/?$ /$1 [R=301,NC,L]
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

# to redirect /forums/f8/39840-something.html to
# /showthread.php?t=39840
RewriteRule ^forums/[^/]+/([^-]+)-[^.]+\.html$ /showthread.php?t=$1 [R=301,NC,L,QSA]

# to redirect /forums//showthread.php?t=39840 to
# /showthread.php?t=39840
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^forums/([^/]+)/?$ /$1 [R=301,NC,L]