Home Home » » Blog Tips Blog Tips

How to remove forum and topic keyword from bbpress url Hoe te verwijderen forum en topic trefwoord uit bbPress url

I had been trying lot of forum softwares ( around 5 till now ) from last Friday and was testing BBPRESS yesterday. Ik had geprobeerd veel forum softwares (ongeveer 5 tot nu toe) van afgelopen vrijdag en was het testen van BBPress gisteren. The new version9.x has lot of improvement over its 8.x version but one thing I found common in both of them De nieuwe version9.x heeft veel verbetering ten opzichte van haar 8.x versie, maar een ding vond ik vaak bij beide

  • “Forum” keyword was appended when you accesss any forum eg http://sitename.com/<forum-directory>/ forum /<forum slug> "Forum" keyword was toegevoegd wanneer u accesss elk forum bijv. http://sitename.com/ <forum-directory> / forum / <forum slug>
  • “topic” keyword was also appended for every post made eg http://sitename.com<forum-directory>/ topic /<actualy topic slug> "Onderwerp" keyword werd ook toegevoegd voor elk bericht gemaakt bijv. http://sitename.com <forum-directory> / topic / <actualy onderwerp slug>

Now I understand why both the keywords are reqired but again from SEO point it has no meaning unless somebody runs a forum on “forums” topic. Nu begrijp ik waarom zowel de zoekwoorden zijn reqired maar weer van SEO punt heeft geen zin, tenzij iemand loopt een forum over "forums" onderwerp. The next thing I did was look around for a hack and luckily Het volgende wat ik deed was rond te kijken voor een hack en gelukkig at this post there was a solution op deze post was er een oplossing , but not actual plugin was supported. , Maar niet de werkelijke plugin werd gesteund. I copied the code given there and tested around and was successful. Ik kopieerde de code daar gegeven en getest rond en was succesvol.

Before I start, I have just tested around with the code given by the memebers over there. Voordat ik begin, heb ik net getest rond met de code die door de Memebers daar. So test it before you use it. Dus testen voordat u deze gebruikt. And moreover I am not supporting it as I did not make it and cant do it either. En bovendien ben ik niet steunen als ik het niet maken en cant beide doen.

I made a plugin from the code given and took re-write code for .htaccess files. Ik maakte een plugin die met de code en nam herschreven code voor. Htaccess bestanden. Here is how they look Hier is hoe ze eruit

PLUGIN:( Taken from the forum link ) Plugin: (Taken van het forum link)

<?php <? php
/* / *
Plugin Name: Remove Topic Forum Plugin Naam: Verwijder Topic Forum
Plugin URI: http://bbpress.org/ Plugin URI: http://bbpress.org/
Description: Allows to remove forum and topic word in url Beschrijving: Maakt het mogelijk om forum en onderwerp woord verwijderen in url
Author: Ashish Mohta Auteur: Ashish Mohta
Version: 1.0 Versie: 1.0
Author URI: http://www.technospot.net/blogs/ Auteur URI: http://www.technospot.net/blogs/
*/ * /

function my_get_forum_link_filter( $link , $forum_id = 0 ) { functie my_get_forum_link_filter ($ link, $ forum_id = 0) (
//retrieve the forum object / / ophalen van het forum object
$forum = get_forum( get_forum_id( $forum_id )); $ forum = get_forum (get_forum_id ($ forum_id));

//check for rewrite / / controleren of herschrijven
$rewrite = bb_get_option( 'mod_rewrite' ); $ herschrijven = bb_get_option ( 'mod_rewrite');
if ( $rewrite ) { if ($ herschrijven) (
//what kind of rewrite there is? / / wat voor soort herschrijven er is? slug use “forum_slug” column, else the column is “forum_id” slug gebruik "forum_slug" kolom, anders wordt de kolom "forum_id"
$column = ($rewrite === 'slugs')?('forum_slug'):('forum_id'); $ kolom = ($ herschrijven === 'naaktslakken')?(' forum_slug'):(' forum_id');

// change /forum/pets-discussions in /pets-discussions / / Change / forum / huisdieren-besprekingen in / huisdieren-besprekingen
// this work only if the rewrite module is modded! / / Dit werk alleen als de rewrite module is modded!
// and this work only if the slugged name will NEVER / / En dit alleen werken als de klap naam zal NOOIT
// be a reserved word like “rss” or “bb-images” / / Een gereserveerd woord als "RSS" of "bb-images"
// and this is achieved by a filter on bb_slug_sanitize / / En dit wordt bereikt door een filter op bb_slug_sanitize
$link = str_replace('forum/' . $forum->$column , $forum->$column, $link); $ link = str_replace ( "forum / '. $ forum-> $ kolom, $ forum-> $ kolom, $ link);
} )
return $link.”/”; // Very important line! return $ link ."/"; / / Heel belangrijk lijn! // Added extra slash :Ashish / / Added extra slash: Ashish
} )

add_filter( 'get_forum_link', 'my_get_forum_link_filter' ); add_filter ( 'get_forum_link', 'my_get_forum_link_filter');

function my_get_topic_link_filter( $link, $topic_id = 0) { functie my_get_topic_link_filter ($ link, $ TOPIC_ID = 0) (
//retrieve the topic object / / ophalen het onderwerp object
$topic = get_topic( get_topic_id( $topic_id )); $ topic = get_topic (get_topic_id ($ topic_id));

//retrieve the forum object that is the topic container / / ophalen het forum object dat is het onderwerp container
$forum = get_forum( get_forum_id( $topic->forum_id )); $ forum = get_forum (get_forum_id ($ topic-> forum_id));

//check for rewrite / / controleren of herschrijven
$rewrite = bb_get_option( 'mod_rewrite' ); $ herschrijven = bb_get_option ( 'mod_rewrite');
if ( $rewrite ) { if ($ herschrijven) (
//what kind of rewrite there is? / / wat voor soort herschrijven er is? slug use “forum_slug” column, else the column is “forum_id” slug gebruik "forum_slug" kolom, anders wordt de kolom "forum_id"
$column = ($rewrite === 'slugs')?('forum_slug'):('forum_id'); $ kolom = ($ herschrijven === 'naaktslakken')?(' forum_slug'):(' forum_id');

//create the “forum/pets-discussions” chunk to show the hierarchical relation forum->topic / / maak het "forum / huisdieren-discussies" chunk om aan te tonen de hiërarchische relatie forum-> onderwerp
$forum_nice_uri = “forum/” . $ forum_nice_uri = "forum /". $forum->$column . $ forum-> $ kolom. “/”; "/";

//attach the hierarchical chunk to the link / / attach de hiërarchische chunk om de koppeling
$link = str_replace(bb_get_option('uri'), bb_get_option('uri') . $forum_nice_uri, $link); $ link = str_replace (bb_get_option ( 'uri'), bb_get_option ( 'uri'). forum_nice_uri $, $ link);

// change /forum/pets-discussions/topic/my-sweet-dog in /pets-discussions/my-sweet-dog / / Change / forum / huisdieren-discussie / topic / my-sweet-hond in / pets-discussions/my-sweet-dog
// this work only if the rewrite module is modded! / / Dit werk alleen als de rewrite module is modded!
// and this work only if the slugged name will NEVER / / En dit alleen werken als de klap naam zal NOOIT
// be a reserved word like “rss” or “bb-images” / / Een gereserveerd woord als "RSS" of "bb-images"
// and this is achieved by a filter on bb_slug_sanitize / / En dit wordt bereikt door een filter op bb_slug_sanitize
$link = str_replace('forum/' . $forum->$column , $forum->$column, $link); $ link = str_replace ( "forum / '. $ forum-> $ kolom, $ forum-> $ kolom, $ link);
$link = str_replace('topic/' . $topic->$column , $topic->$column, $link); $ link = str_replace ( 'onderwerp /'. $ topic-> $ kolom, $ topic-> $ kolom, $ link);
} )

return $link.”/” ; // Very important line! return $ link. "/" / / Heel belangrijk lijn! // Added Extra Slash :Ashish / / Added Extra Slash: Ashish
} )

add_filter( 'get_topic_link', 'my_get_topic_link_filter' ); add_filter ( 'get_topic_link', 'my_get_topic_link_filter');

function my_bb_slug_sanitize_filter( $text_slug, $text_original = ”, $length = 0 ) { functie my_bb_slug_sanitize_filter ($ text_slug, $ text_original = ", $ length = 0) (
// add “r-” by regex when the string begins with “bb-” or “my-” or is a reserved word / / Add "R-" door regex wanneer de string begint met "BB-'of' mijn 'of is een gereserveerd woord
return preg_replace('/^(my-.*|bb-.*|rss|tags|view|profiles)$/', 'r-$1′, $text_slug); return preg_replace ('/^( mijn-.* | bb-.* | rss | tags | View | profielen )$/', 'r-$ 1', $ text_slug);
} )

add_filter( 'bb_slug_sanitize', 'my_bb_slug_sanitize_filter' ); add_filter ( 'bb_slug_sanitize', 'my_bb_slug_sanitize_filter');

?> ?>

.htcaccess file: . htcaccess bestand:

( Taken from one same forum link and modified a little. You will need to remove the MULTIVIEW from your existing .htaccess file ) (Op grond van hetzelfde forum een link en een beetje bewerkt. U moet de Multiview verwijderen uit uw bestaande. Htaccess-bestand)

<IfModule mod_rewrite.c> <IfModule Mod_rewrite.c>
RewriteEngine On RewriteEngine On
RewriteBase /forums RewriteBase / forums

Options +FollowSymlinks Opties + FollowSymLinks

RewriteRule ^tags/([^/]+)/page/([0-9]+)/?$ tags.php?tag=$1&page=$2 [L,QSA] Tags /([^/]+)/ RewriteRule ^ page / ([0-9 ]+)/?$ tags.php? Tag = $ 1 & page = $ 2 [L, QSA]
RewriteRule ^tags/([^/]+)/?$ tags.php?tag=$1 [L,QSA] RewriteRule ^ tags /([^/]+)/?$ tags.php? Tag = $ 1 [L, QSA]
RewriteRule ^tags/?$ tags.php [L,QSA] RewriteRule ^ tags /? $ Tags.php [L, QSA]
RewriteRule ^profile/([^/]+)/page/([0-9]+)/?$ profile.php?id=$1&page=$2 [L,QSA] Profiel /([^/]+)/ RewriteRule ^ page / ([0-9 ]+)/?$ profile.php? Id = $ 1 & page = $ 2 [L, QSA]
RewriteRule ^profile/([^/]+)/([^/]+)/?$ profile.php?id=$1&tab=$2 [L,QSA] RewriteRule ^ profiel /([^/]+)/([^/]+)/?$ profile.php? Id = $ 1 & tab = $ 2 [L, QSA]
RewriteRule ^profile/([^/]+)/([^/]+)/page/([0-9]+)/?$ profile.php?id=$1&tab=$2&page=$3 [L,QSA] Profiel /([^/]+)/([^/]+)/ RewriteRule ^ page / ([0-9 ]+)/?$ profile.php? Id = $ 1 & tab = $ 2 & page = $ 3 [L, QSA ]
RewriteRule ^profile/([^/]+)/?$ profile.php?id=$1 [L,QSA] RewriteRule ^ profiel /([^/]+)/?$ profile.php? Id = $ 1 [L, QSA]
RewriteRule ^view/([^/]+)/page/([0-9]+)/?$ view.php?view=$1&page=$2 [L,QSA] RewriteRule ^ bekijken /([^/]+)/ page / ([0-9 ]+)/?$ view.php? View = $ 1 & page = $ 2 [L, QSA]
RewriteRule ^view/([^/]+)/?$ view.php?view=$1 [L,QSA] RewriteRule ^ bekijken /([^/]+)/?$ view.php? View = $ 1 [L, QSA]
RewriteRule ^rss/?$ rss.php [L,QSA] RewriteRule ^ rss /? $ Rss.php [L, QSA]
RewriteRule ^rss/forum/([^/]+)/?$ rss.php?forum=$1 [L,QSA] RewriteRule ^ rss / forum /([^/]+)/?$ rss.php? Forum = $ 1 [L, QSA]
RewriteRule ^rss/topic/([^/]+)/?$ rss.php?topic=$1 [L,QSA] RewriteRule ^ rss / onderwerp /([^/]+)/?$ rss.php? Topic = $ 1 [L, QSA]
RewriteRule ^rss/tags/([^/]+)/?$ rss.php?tag=$1 [L,QSA] RewriteRule ^ rss / tags /([^/]+)/?$ rss.php? Tag = $ 1 [L, QSA]
RewriteRule ^rss/profile/([^/]+)/?$ rss.php?profile=$1 [L,QSA] Rss RewriteRule ^ / profiel /([^/]+)/?$ rss.php? Profiel = $ 1 [L, QSA]

RewriteRule ^([^.]+)/([^.]+)/page/([0-9]+)/?$ topic.php?id=$2&page=$3 [L,QSA] RewriteRule ^([^.]+)/([^.]+)/ page / ([0-9 ]+)/?$ topic.php? Id = $ 2 & page = $ 3 [L, QSA]
RewriteRule ^([^/.]+)/([^.]+)/?$ topic.php?id=$2 [L,QSA] RewriteRule ^([^/.]+)/([^.]+)/?$ topic.php? Id = $ 2 [L, QSA]

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

Place the plugin file in my-plugin directory and .htaccess file in bbpress root directory. Plaats het plugin bestand in mijn-plugin directory en. BbPress htaccess-bestand in de root directory. Active the plugin. Actieve de plugin. and it should work fine. en het moet prima werken.

The Problem I find with this. Het probleem vind ik met dit.

  • The Link to BBpress admin board link does not work from main site. De link naar BBPress admin board-link werkt niet van de belangrijkste site. It redirects to home page. Het redirects to home page. You will need to manually type the link to go inside. U moet handmatig de link naar binnen te gaan.
  • In case you type something which does not exists as http://sitename.com/<bbpress-directory>/sdaksda it returns http://sitename.com/<bbpress-directory>// . An extra slash . In het geval je iets dat niet bestaat als http://sitename.com/ <bbpress-directory> / sdaksda het terugkeert http://sitename.com/ <bbpress-directory> / /. Een extra slash.

Except these 2 there is no problem I see so far but Its not easy to predict as I dont have lot of posts or users. Behalve deze 2 is er geen probleem dat ik zie tot nu toe maar zijn niet makkelijk te voorspellen wat ik dont zijn veel berichten of gebruikers. So if you want to try it out Dus als je het wilt uitproberen download the files here Download de bestanden hier . . You can give your feedback here if you can improve it. U kunt uw feedback hier als je deze kunt verbeteren. And If somebody wants they can support the plugin and enhance it. En als iemand wil ze de plugin kunnen ondersteunen en te verbeteren. You can see U kunt demo of this on the forum demo van dit op het forum I tested on but You wont be able to register and anyways it just a test forum Ik heb getest, maar op You wont kunnen inschrijven en het hier of daar net een test forum

Tagged with: Tagged met: | Need more help ? | Meer hulp nodig? Ask your Questions at our Stel uw vragen aan onze Support Center Ondersteuning | Follow us on Twitter | Volg ons op Twitter @TSNW @ TSNW or of Facebook Facebook
Facebook SharePrint This Post

Translate to EnglishÜbersetzen Sie zum Deutsch/GermanΜεταφράστε στα ελληνικά/GreekПереведите к русскому/RussianOversetter til Norsk/NorwegianÖversätta till Svensk/Swedishहिन्दी अनुवाद करने के लिए/Hindi
Tradueix al català/CatalanTulkot uz latviešu/LatvianPreložiť do slovenčiny/SlovakVertaal aan het Nederlands/Dutchترجمة الى العربية/ArabicTraduzca al Español/SpanishTraduisez au Français/French
Traduca ad Italiano/ItalianTraduza ao Português/Portuguese日本語に翻訳しなさい /Japanese한국어에게 번역하십시오/Korean中文翻译/Chinese Simplified中文翻译/Chinese TraditionalПереклад на українську/Ukrainian

Posted on 4th April 2008 by Geplaatst op 4 april 2008 door Ashish Mohta Ashish Mohta , A tech blogger who writes about solving day to day problems of people who use computer. , Een tech blogger die schrijft over het oplossen van dagelijkse problemen van mensen die gebruik maken van de computer. He also writes on How to use the applications like Office, PC tips, Online tools,Browsers and more. All posts by Hij schrijft ook op hoe te om de toepassingen zoals Office, pc tips, Online tools, Browsers en meer gebruik. Alle posts van Ashish Mohta Ashish Mohta | Connect with me @ | Verbind met mij @ Twitter Twitter | | Linkedin Linkedin | | Facebook Facebook | | Stumble Stumble

One Comment Een Commentaar » »

  • Tommie said: Tommie schreef:

    Thanks! Bedankt! It works wonders. Het werkt wonderen. Running it now on the community site Callofduty.se. Running zij nu op de community site Callofduty.se. Your sh*t is the only EASY solution to this problem – thanks again! Uw sh * t is de enige simpele oplossing voor dit probleem - thanks again!

    (Running it with bbPress 1.01 if anyone would like to know) (Running met bbPress 1,01 als iemand zou willen weten)

Leave your response! Laat uw reactie!

Be nice. Wees aardig. Keep it clean. Keep it clean. Stay on topic. Stay on topic. No spam. Geen spam.