Skip to:

Re: Rewriting?

Hey I’m been trying to get this to work also. And have posted to some other similar threads here, but there haven’t gotta a solution working.

Here’s what I’ve learned.

1. From what I gathered, the problem is with how bbPress redirects its pages. Even if you have the proper mod_rewrite rules, bbPress will automatically redirect the rewritten URL to the full URL that it thinks the page is supposed to have. This basically makes custom mod_rewrite useless.

2. You can prevent bbPress from redirecting by fooling bbPress into thinking it should have a different URL than its supposed to. You can do this by modifying the get_forum_link, get_topic_link, get_user_profile link, etc. functions in the template-functions.php file. The idea is to use pattern matching to strip out the base directory from the URL.

function get_user_profile_link( $id = 0, $page = 1 ) {
$user = bb_get_user( bb_get_user_id( $id ) );
$rewrite = bb_get_option( 'mod_rewrite' );
if ( $rewrite ) {
if ( $rewrite === 'slugs' ) {
$column = 'user_nicename';
} else {
$column = 'ID';
$r = bb_get_option('uri') . "profile/" . $user->$column . ( 1 < $page ? "/page/$page" : '' );
} else {
$r = bb_get_option('uri') . "profile.php?id=$user->ID" . ( 1 < $page ? "&page=$page" : '' );

$r = str_replace('forums/profile/' . $user->$column , "profile/" . $user->$column, $r);
return apply_filters( 'get_user_profile_link', $r, $user->ID );

3. If you strip out the base directory from the URL however, it makes bbPress think you’re no longer logged in, and you can’t log in. I still can’t figure out a fix yet.

Seems like a lot of people are having issues with mod_rewrite in bbPress. Hopefully the next update will resolve some of these issues.

Skip to toolbar