Skip to:

Changing Mod Rewrite rules

  • Hi,

    I’ve successfully installed bbPress and Pretty Premalinks on my site. I want to modify the Premalinks.

    For example:

    to become

    I tried to modify the admin/rewrite-rules.php.

    RewriteRule ^forum/([0-9]+)/page/([0-9]+)$ <?php bb_option( ‘path’ ); ?>forum.php?id=$1&page=$2 [L,QSA]

    My ideea was:

    RewriteRule ^forum-([0-9]+)/page/([0-9]+)$ <?php bb_option( ‘path’ ); ?>forum.php?id=$1&page=$2 [L,QSA]

    However all the changes I do the rewrite-rules.php give an error and do not modify the ULR. Is there another file where the rewrite-rules are configured?

    Thanx for the support.

Viewing 8 replies - 1 through 8 (of 8 total)
  • I’ve read some posts and it looks that lots of people want to play with their permalinks. WP handles great this link customization but I was unable to find anything for bbPress. Does anyone had any success with changing the mod_rewrite rules and modifying the current permalinks?


    I don’t know anyone that has successfully done it (at least I can’t remember a post or anyone bragging about it), but I created a TRAC ticket for a future version on this issue:

    You might be able to play with rewrite-rules.php in the /bb-admin/ folder to get some direction on what to change in the meantime to play with it, but I don’t believe it is pluggable (for a plugin).


    Sam Bauers


    All the magic happens in bb_repermalink() in bb-includes/function.php but the real problem here is that get_path() splits by “/” to find out the topic/forum/user id.

    You could plugin to bb_repermalink() and change the value of $permalink that way.

    e.g. if your permalinks were of the form, forum-12, topic-34 etc. (already setup in your .htaccess file)

    You could make the following file…

    function my_pre_permalink() {
    $p = get_path(0);
    $p = split('-', $p);
    $p = $p[1];
    return $p;

    add_action('pre_permalink', 'my_pre_premalink');

    Drop that into your plugins directory and it should work.

    Of course I haven’t tested this, but it should work in theory.

    Sam Bauers


    Actually, it’s harder than this. What I wrote above is only a part of the issue. I’m working on a patch at the moment.

    Sam Bauers


    Here’s a sneak peak at the patch functionality….

    Still working out a few details.



    Nice. Keep rockin’ it.



    Open bb-includes/template-functions.php and change:

    $link = bb_get_option(‘uri’) . “forum/$forum->forum_id” . ( 1 < $page ? “/page/$page” : ” );


    $link = bb_get_option(‘uri’) . “forum-$forum->forum_id” . ( 1 < $page ? “/page/$page” : ” );

    Now open your .htaccess file and change:

    RewriteRule ^forum/(.+)/page/?([0-9]{1,})/?$ forum.php?id=$1&page=$2 [QSA,L]

    RewriteRule ^forum/(.+)/?$ forum.php?id=$1 [QSA,L]


    RewriteRule ^forum-(.+)/page/?([0-9]{1,})/?$ forum.php?id=$1&page=$2 [QSA,L]

    RewriteRule ^forum-(.+)/?$ forum.php?id=$1 [QSA,L]


    I’ve made something similar. It still needs some work. You can see the result at and download the plugin from

    This is my first plugin wrote and it needs some more work with the .htaccess rules. The pagination is not yet fixed and if somone could help me please let me know.


Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
Skip to toolbar