bbPress

Simple, Fast, Elegant

bbPress support forums » Troubleshooting

Changing Mod Rewrite rules

(9 posts)
  • Started 1 year ago by Mirce
  • Latest reply from Mirce
  • This topic is not resolved

Tags:

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

    Posted 1 year ago #
  2. 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.

    Posted 1 year ago #
  3. 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:

    http://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

    Posted 1 year ago #
  4. 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.

    Posted 1 year ago #
  5. 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.

    Posted 1 year ago #
  6. 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.

    Posted 1 year ago #
  7. Nice. Keep rockin' it.

    Posted 1 year ago #
  8. 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

    Posted 1 year ago #
  9. 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 http://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.

    Posted 1 year ago #

RSS feed for this topic

Reply

You must log in to post.

Code is Poetry.