Forums

Join
bbPress Support ForumsTroubleshootingHelp! 404 error, but page displays

Info

Help! 404 error, but page displays

  1. The Google webmaster tools are showing my forum pages as 404 (Not Found), but if I browse to the pages they seem fine in the browser.

    So I went to http://web-sniffer.net/ and found that all of my forum pages are returning HTTP status code 404, but the correct page content (?!).

    I tried a simple static page in the forum folder, and that works fine.

    Any ideas as to what might be going on here?

  2. Interesting... the BuddyPress forums (http://bbpress.org/forums/) have the same problem, but the bbPress.org forums are fine.

    I know that the BP forums and our site both use deep integration, so I tried removing that. Result: No more 404.

    So it appears that deep integration is part of this problem.

    I have bbPress 1.0.2, WPMU 2.8.4a and BuddyPress 1.0.3.

  3. Looks like WordPress is setting the 404 because it doesn't recognize the bbPress page that is loading.

    When the global WP object is constructed, the function WP->handle_404 calls "status_header( 404 )".

    As a workaround, I modified "handle_404" to lay off the 404 if "BB_PATH" is defined (i.e. when a bbPress page is loading). This seems to work ok.

    Here's the new "handle_404" at around line 445 in "wp-includes/classes.php".

    function handle_404() {
    		global $wp_query;
    
    		if ( !defined( 'BB_PATH' ) && (0 == count($wp_query->posts)) && !is_404() && !is_search() && ( $this->did_permalink || (!empty($_SERVER['QUERY_STRING']) && (false === strpos($_SERVER['REQUEST_URI'], '?'))) ) ) {
    
    			// Don't 404 for these queries if they matched an object.
    			if ( ( is_tag() || is_category() || is_author() ) && $wp_query->get_queried_object() ) {
    				if ( !is_404() )
    					status_header( 200 );
    				return;
    			}
    			$wp_query->set_404();
    			status_header( 404 );
    			nocache_headers();
    		} elseif ( !is_404() ) {
    			status_header( 200 );
    		}
    	}
  4. This topic is closed