Info
- 9 posts
- 5 voices
- Started 5 years ago by Mirce
- Latest reply from Mirce
- This topic is not resolved
Changing Mod Rewrite rules
-
- Posted 5 years ago #
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-1I 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 5 years ago #
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 5 years ago #
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 4 years ago #
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 4 years ago #
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 4 years ago #
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 4 years ago #
Nice. Keep rockin' it.
-
- Posted 4 years ago #
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 4 years ago #
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.
-
You must log in to post.