Welcome

Welcome to the Forums, Blogs, Wikis discussion boards. If you're new here please take a moment to register for an account. If you're already a member here, welcome back. Please login to join in.

Forums, Blogs, Wikis » Software » Forums

bbPress, WordPress, and 404 Errors

  1. This forum is wrapped inside the WordPress theme to keep the style consistent across the site. To do that I included the WordPress blog-header.php file because I needed to be able to use the sidebar widgets even though the forum software is technically running separately.

    I noticed a major problem though. Even though the forum pages are displaying correctly, the server is returning a 404 header so search engines think the page isn't there. I know the reason is because I'm including that blog-header.php file and WordPress thinks the forum page doesn't exist. But I'm looking for a solution to what seems to be a fairly significant problem.

    And I did find a WordPress plugin that overrides the 404 header by sending a 200 header later, but that seems like it would cause even the correctly sent 404s to be overridden as well and that doesn't do any good.

    Ryan
    Posted 2 years ago #
  2. Found a partial solution at the bbPress support forum. It involved writing a WordPress plugin to add a few rewrite rules. Forum topic and board indexes seem to be returning 200 headers like they should be. The only problem is that if I browse to a non-existing thread id and the bbPress error message shows for topic not found the header is still a 200.

    Posted 2 years ago #
  3. Turns out I needed to edit the plugin code a little to take care of the tag and profile links since they were still returning 404s.

    Here is the completed code.

    <?php
    /*
    Plugin Name: bbPress 404 Fixer
    Description: Fixes 404 errors in bbPress wrapped in WordPress
    Version: 0.0.1
    */
    function forum_flush_rewrites() {
    global $wp_rewrite;
    $wp_rewrite->flush_rules();
    }
    add_action('init', 'forum_flush_rewrites');
    function forum_add_rewrites($wp_rewrite) {
    add_rewrite_rule('forum/topic', 'forum/topic.php');
    add_rewrite_rule('forum/forum', 'forum/forum.php');
    add_rewrite_rule('forum/profile', 'forum/profile.php');
    add_rewrite_rule('forum/tags', 'forum/tags.php');
    add_rewrite_rule('forum', 'forum/index.php');
    $wp_rewrite->rules = array_merge($wp_rewrite->non_wp_rules, $wp_rewrite->rules);
    }
    add_action('generate_rewrite_rules', 'forum_add_rewrites');
    ?>

    Posted 2 years ago #
  4. wvoelcker
    Member

    You are a life-saver. Thank you so much.

    Posted 1 year ago #

RSS feed for this topic

Reply

You must log in to post.