Skip to:
Content
Pages
Categories
Search
Top
Bottom

Changing Mod Rewrite rules

  • Hi,

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

    For example:

    http://www.example.com/forum/1

    to become

    http://www.example.com/forum-1

    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?

    Thanx.

    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:

    https://trac.bbpress.org/ticket/579

    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).

    Trent


    Sam Bauers
    Participant

    @sambauers

    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
    Participant

    @sambauers

    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
    Participant

    @sambauers

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

    http://www.network.net.au/bbpress/patches/permalinks/teaser.gif

    Still working out a few details.


    Nate
    Member

    @nateolson

    Nice. Keep rockin’ it.


    bbpressfriend
    Member

    @bbpressfriend

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

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

    to

    $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]

    to

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

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

    bye

    I’ve made something similar. It still needs some work. You can see the result at http://www.dfur.com and download the plugin from https://bbpress.org/forums/topic/771

    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.

    Thanx.

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