【问题标题】:How can I resolve these vbulletin 404 errors using htaccess?如何使用 htaccess 解决这些 vbulletin 404 错误?
【发布时间】:2013-07-22 19:38:58
【问题描述】:

我有一个非常大的论坛(23 万个线程,300 万个帖子),在 Google 网站管理员工具上报告了大量 404 个页面,大约有 14,000 个 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 中删除 forums/,这些:

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 mod-rewrite http-status-code-404 vbulletin


    【解决方案1】:

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

    RewriteEngine on
    RewriteBase /
    
    # removes "forums/"
    RewriteCond %{REQUEST_URI} !^/showthread.php$ [NC]
    RewriteRule ^forums/([^/]+)$ $1 [R=301,NC,L]
    
    # parses thread id
    RewriteCond %{REQUEST_URI} !^/showthread.php$ [NC]
    RewriteRule ^forums/[^/]+/(\d+)-.*$ showthread.php?t=$1 [R=301,NC,L]
    

    【讨论】:

      【解决方案2】:

      通过httpd.conf启用mod_rewrite和.htaccess,然后把这段代码放到你.htaccessDOCUMENT_ROOT目录下:

      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]
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-03-08
        • 1970-01-01
        • 2014-02-19
        • 1970-01-01
        • 1970-01-01
        • 2011-07-25
        • 2014-06-04
        • 1970-01-01
        相关资源
        最近更新 更多