[bbDev] Permalinks Plugin - Changing Mod Rewrite Rules

Michael D Adams mikea at turbonet.com
Wed Mar 14 03:52:27 GMT 2007


On Mar 13, 2007, at 12:36 PM, info at swing-sets.us wrote:
> Hello,
> I am trying to change the bbPress permalinks but I am stuck when it  
> comes to paggination. I've already written a plugin and I have a  
> working example at www.dfur.com
>
> My permalinks structure idea is
> www.example.com/forum_name
> www.example.com/forum_name/page/2 for pagination
> www.example.com/forum_name/topic_id
> www.example.com/forum_name/topic_id/page/2 for pagination
>
> Pagination can be change from page/2 to page_2, same thing with the  
> topic_id.
>
> There are 2 reasons for witch I am working on this:
> 1. www.example.com/forum_name/topic_id will offer better usability  
> and help with the search engine rankings
> 2. A custom permalink structure will allow other platform forums  
> owners to switch to bbPress AND keep their current linking  
> structure. I have a PHPBB forum that I want to move to bbPress but  
> if I will loose all the links there will be a nightmare restoring  
> all my rakings.
>
> I?ve written a plugin that changes the forum links to  
> www.example.com/forum_name.
> You can see a working example on my test site www.dfur.com, the  
> plugin can be downloaded from http://bbpress.org/forums/topic/771
> To make this work I?ve added in to following link for each topic of  
> my site in htaccess
> RewriteRule ^designer_furniture/topic([0-9]+)$ /topic.php?id=$1  
> [L,QSA]
>
> The problem comes to pagination. Please see http://www.dfur.com/ 
> designer_furniture
> The ?page 2? pagination should be http://www.dfur.com/ 
> designer_furniture/page/2 However this link does not works. The 301  
> from bb_repermalink function in bb-includes/functions.php redirect  
> me back to the forum category.

You'll also need above that:
RewriteRule ^designer_furniture/topic([0-9]+)/page/([0-9]+)/?$ / 
topic.php?id=$1&page=$2

> From what I?ve understood the bb_repermalink makes a check to see  
> if the links is correctly created: if - ( is_forum() )? $permalink  
> = get_forum_link( $permalink, $page ); and if this fails it gives  
> the 301 redirect.
> From my point of view creating a 301 (permanently moved) is not a  
> good move for search engines, especially Google. The 301 may cause  
> a duplicate page issue with Google. The standard recommendation for  
> a non existing page is a 404 with a noindex, nofollow. I see that  
> the wordpress and bbpress forums have the 404 but the regular  
> bbpress powered forums do not have this option.

The bb_repermalink function is designed to take urls like  
example.com/?forum_id=1 (a URL that definitively points to a valid  
page but does so with an incorrect URL) and turn them into  
example.com/forum/1 (the canonical URL for that page).

For that, 301 is the correct behavior.  301s should not cause  
duplication (as long as instead 404 when the page does not exist OR  
we 404 after being redirected to page that does not exist).

If we don't eventually 404 on non-existent pages, we should.

Currently bb_repermalink is very inflexible, something I hope which a  
patch Sam Bauers is working on will fix :)

Michael


More information about the bbDev mailing list