Skip to:
Content
Pages
Categories
Search
Top
Bottom

How do I get wp_redirect + mod_rewrite to behave?

  • mod_rewrite and wp_redirect don’t seem to like each other. I’m running into problems with the wp_redirect functions in bbPress redirecting the page after the URL has been rewritten, so that the URL changes back to the longer form.

    For example, this mod_rewrite rule:

    RewriteRule ^profile/username forums/profile/username [L]

    will rewrite:

    http://www.example.com/profile/username

    to:

    http://www.example.com/forums/profile/username

    Except, that after its been rewritten, bbPress forces a redirection via wp_redirect, causing the URL in the browser window to change to the longer form. Any suggestions?

    Commenting out lines 2061 and 2062 in the bbPress functions.php file will stop wp_redirect from redirecting the page.

    if ( $check != $uri && $check != str_replace(urlencode($_original_id), $_original_id, $uri) ) {
    //wp_redirect( $permalink );
    //exit;
    }

    But this breaks authentication, and causes bbPress to think you are not logged in, even if you are.

  • You must be logged in to reply to this topic.
Skip to toolbar