Skip to:
Content
Pages
Categories
Search
Top
Bottom

Permalinks Slugs Modification – removing forum

Viewing 16 replies - 1 through 16 (of 16 total)

  • Sam Bauers
    Participant

    @sambauers

    Without core hacks or writing your own plugin that hooks into the get_forum_link function and the bb_repermalink function it’s not possible. Your .htaccess file may be correct, but the links generated on the forum won’t work without changing the what those functions expect. I suggest you change the name of the subdirectory you are placing your forums in – that would be the path of least resistance..

    Thanx for the response.

    I tried to follow how the links are made in functions.php. In bb_repermalink() the case ‘forum-page’ needs to be “hacked”

    $forum_id = bb_get_id_from_slug(‘forum’, $permalink);

    Is the ‘forum’ the “forum” I want to remove?

    Thanx.


    Sam Bauers
    Participant

    @sambauers

    > Is the ‘forum’ the “forum” I want to remove?

    No. It’s a little more complicated than that. In fact, that part you say needs to be hacked, needs to be left completely alone. Really, you are asking for a world of pain by attempting this. It took me hours to write and test the slugs support. Seriously, just rename your forum directory – it’s not worth the hours you will spend.

    There has got to be a fairly easy way to remove the “forums/” slug from the URL… anyone know how yet?

    Hey, I’m trying to figure this out also. Anyone figured out a way to remove the first “forum” in http://www.example.com/forum/forum/forum-name. So that the URL is shorter? I tried doing it with mod_rewrite, but having some issues with bbPress automatically redirecting.

    I did something similar, but it required a core hack. I renamed the second “forum” to “board”. It required two steps:

    1. With version 0.8.3, I modified line 363 of /bb-includes/template-functions.php to this:

    $link = bb_get_option( 'uri' ) . "board/" . $forum->$column . ( 1 < $page ? "/page/$page" : '' );

    2. I created an htaccess file by copying the text from /bb-admin/rewrite-rules.php, with two extra lines:

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

    Hey bobby, just curious. Why did you have to change the second “forum” to “board”? Is there anyway to just leave it as “forum”?

    I wanted the forum-specific URLs to look like this:

    * http://boards.weddingbee.com/board/beehive

    If you make the right edits to that core file and an htaccess file, I think the URL can be anything you want…

    Hi bobby, I tried out your hack in bbPress 0.9, and it doesn’t seem to work. Here’s what I did:

    I have my bbPress directory installed in a directory called “forums” in the root web directory. So the URL to access the forums’ home page is:

    http://www.example.com/forums

    and accessing a forum titled “test forum” is at this URL:

    http://www.example.com/forums/forum/test-forum

    a topic titled “test topic” is at this URL:

    http://www.example.com/forums/topic/test-forum

    I implemented your hack, and changed “forum” to “board” in the template-functions.php. I copied the rewrite rules from rewrite-rules.php and placed them into .htaccess file in the root web directory. I also added the two lines of code you suggested in that file:

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

    I also tried adding this to the rewrite-rules.php:

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

    When I go to this URL:

    http://www.example.com/board/test-forum

    I get a 404 error.

    However, when I go to this url:

    http://www.example.com/forums/forum/test-forum/

    It redirects and changes the URL in the address bar in the browser window changes:

    http://www.example.com/forums/board/test-forum/

    That also brings up a 404 page.

    Also, when I go this URL:

    http://www.example.com/topic/test-topic

    The URL works, but it redirects and changes the URL in the address bar in the browser window changes to:

    http://www.example.com/forums/topic/test-forum

    I am a little perplexed as to what is going on.

    Can you post a link to your site?

    Hey bobby, here it is here:

    http://www.lifeclever.com/forums/

    You said: “I also tried adding this to the rewrite-rules.php”. That’s unnecessary. You just need to add those lines to your htaccess file, which should contain the contents of the page located at http://www.lifeclever.com/forums/bb-admin/rewrite-rules.php. Did you add those lines to your htaccess file?

    Hi Bobby, yes I added those lines to the .htaccess file as well. It didn’t seem to fix the problem. So I tried adding it to rewrite-rules.php also.

    Just found an earlier thread which hits on a similar problem with shortening the bbPress URL:

    nicer slug url rewrite plugin (done!)

    In the thread’s example. In shows you how to shorten a url like:

    http://www.example.com/bbpress/forum/pets-discussions/topic/my-sweet-dog

    to:

    http://www.example.com/bbpress/pets-discussions/my-sweet-dog

    Now, if it could also be shortened to:

    http://www.example.com/pets-discussions/my-sweet-dog

    That would be even better.


    chrishajer
    Participant

    @chrishajer

    It could work like that I think if there were no website (like WordPress) in the www root. Otherwise, how does the server know it’s a bbPress page vs. a WordPress page?

    If you are running a forum only on a domain, then it would be silly to have it in any sort of directory at all. Otherwise, if you have a website in the root, you have to put bbPress into some sort of directory to prevent confusion.

    Chris, you have a point. However the URL structure of forums and topics always begin with “forum” or “topic”. As in:

    http://www.example.com/bbpress/forum/pets-discussions/

    http://www.example.com/bbpress/topic/my-sweet-dog

    So it would seem that it should be possible to remove the “bbpress” from the URL without interfering with a WordPress installation.

    Having said that, I think the solution proposed in the thread I referred to in my last post (https://bbpress.org/forums/topic/nicer-slug-url-rewrite-plugin-done) is a much more elegant solution for shortening the bbPress URLs.

Viewing 16 replies - 1 through 16 (of 16 total)
  • The topic ‘Permalinks Slugs Modification – removing forum’ is closed to new replies.
Skip to toolbar