Home Hem » » Blog Tips Blogg Tips

How to remove forum and topic keyword from bbpress url Hur tar man bort forum och ämne sökord från bbPress url

I had been trying lot of forum softwares ( around 5 till now ) from last Friday and was testing BBPRESS yesterday. Jag hade försökt många forum softwares (ca 5 hittills) från förra fredagen och testade bbPress igår. The new version9.x has lot of improvement over its 8.x version but one thing I found common in both of them Den nya version9.x har stor förbättring över sin 8.x version men en sak jag hittade vanlig i båda

  • “Forum” keyword was appended when you accesss any forum eg http://sitename.com/<forum-directory>/ forum /<forum slug> "Forum" keyword bifogades när du accesss något forum t.ex. 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> "Topic" keyword bifogades också för varje inlägg som görs t.ex. http://sitename.com <forum-directory> / topic / <actualy ämne 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 förstår jag varför både sökorden reqired men återigen från SEO punkt har det ingen betydelse om någon driver ett forum för "forum" topic. The next thing I did was look around for a hack and luckily Nästa sak jag gjorde var att titta runt efter en hacka och lyckligtvis at this post there was a solution på denna post fanns en lösning , but not actual plugin was supported. , Men inte själva plugin stöddes. I copied the code given there and tested around and was successful. Jag kopierade den kod som anges där och testade runt och var framgångsrik.

Before I start, I have just tested around with the code given by the memebers over there. Innan jag börjar, jag har testat runt med den kod som anges av Memebers därborta. So test it before you use it. Så prova det innan du använder den. And moreover I am not supporting it as I did not make it and cant do it either. Och dessutom jag inte stöder det som jag inte gjorde det och får göra det heller.

I made a plugin from the code given and took re-write code for .htaccess files. Jag gjorde en plugin från en viss kod och tog att skriva kod för. Htaccess filer. Here is how they look Här är hur de ser ut

PLUGIN:( Taken from the forum link ) PLUGIN: (Utdrag från forum länk)

<?php <? php
/* / *
Plugin Name: Remove Topic Forum Plugin Name: Ta bort Ämne Forum
Plugin URI: http://bbpress.org/ Plugin URI: http://bbpress.org/
Description: Allows to remove forum and topic word in url Beskrivning: Används för att avlägsna forum och ämne ord i url
Author: Ashish Mohta Författare: Ashish Mohta
Version: 1.0 Version: 1.0
Author URI: http://www.technospot.net/blogs/ Författare URI: http://www.technospot.net/blogs/
*/ * /

function my_get_forum_link_filter( $link , $forum_id = 0 ) { funktion my_get_forum_link_filter ($ link, $ forum_id = 0) (
//retrieve the forum object / / hämta forum objektet
$forum = get_forum( get_forum_id( $forum_id )); $ forum = get_forum (get_forum_id ($ forum_id));

//check for rewrite / / check för omskrivning
$rewrite = bb_get_option( 'mod_rewrite' ); $ skriva = bb_get_option ( "mod_rewrite ');
if ( $rewrite ) { if ($ skriva) (
//what kind of rewrite there is? / / vilken typ av omskrivning av det? slug use “forum_slug” column, else the column is “forum_id” skogssnigel använda "forum_slug kolumnen, annars kolumnen är" forum_id "
$column = ($rewrite === 'slugs')?('forum_slug'):('forum_id'); $ kolumn = ($ skriva === "stångbitar')?(' forum_slug'):(' forum_id ');

// change /forum/pets-discussions in /pets-discussions / / Ändra / forum / husdjur-diskussioner / husdjur-diskussioner
// this work only if the rewrite module is modded! / / Detta fungerar endast om omskrivning modulen är moddat!
// and this work only if the slugged name will NEVER / / Och det här fungerar endast om slugged namn kommer ALDRIG
// be a reserved word like “rss” or “bb-images” / / Vara ett reserverat ord som "RSS" eller "bb-bilder"
// and this is achieved by a filter on bb_slug_sanitize / / Och detta uppnås genom ett filter på bb_slug_sanitize
$link = str_replace('forum/' . $forum->$column , $forum->$column, $link); $ link = str_replace ( 'forum /'. $ forum-> $ kolumn, $ forum-> $ kolumn, $ link);
} )
return $link.”/”; // Very important line! return $ link ."/"; / / Very important line! // 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) { funktion my_get_topic_link_filter ($ link, $ TOPIC_ID = 0) (
//retrieve the topic object / / hämta ämnet objektet
$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 / / hämta forum objekt som är ämnet container
$forum = get_forum( get_forum_id( $topic->forum_id )); $ forum = get_forum (get_forum_id ($ topic-> forum_id));

//check for rewrite / / check för omskrivning
$rewrite = bb_get_option( 'mod_rewrite' ); $ skriva = bb_get_option ( "mod_rewrite ');
if ( $rewrite ) { if ($ skriva) (
//what kind of rewrite there is? / / vilken typ av omskrivning av det? slug use “forum_slug” column, else the column is “forum_id” skogssnigel använda "forum_slug kolumnen, annars kolumnen är" forum_id "
$column = ($rewrite === 'slugs')?('forum_slug'):('forum_id'); $ kolumn = ($ skriva === "stångbitar')?(' forum_slug'):(' forum_id ');

//create the “forum/pets-discussions” chunk to show the hierarchical relation forum->topic / / skapa "forum / husdjur-diskussioner" bit för att visa det hierarkiska förhållande forum> Topic
$forum_nice_uri = “forum/” . $ forum_nice_uri = "forum /". $forum->$column . $ forum-> $ kolumn. “/”; "/";

//attach the hierarchical chunk to the link / / attach den hierarkiska bit till länken
$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 / / Ändra / forum / husdjur-diskussioner / topic / my-sweet-hunden / pets-discussions/my-sweet-dog
// this work only if the rewrite module is modded! / / Detta fungerar endast om omskrivning modulen är moddat!
// and this work only if the slugged name will NEVER / / Och det här fungerar endast om slugged namn kommer ALDRIG
// be a reserved word like “rss” or “bb-images” / / Vara ett reserverat ord som "RSS" eller "bb-bilder"
// and this is achieved by a filter on bb_slug_sanitize / / Och detta uppnås genom ett filter på bb_slug_sanitize
$link = str_replace('forum/' . $forum->$column , $forum->$column, $link); $ link = str_replace ( 'forum /'. $ forum-> $ kolumn, $ forum-> $ kolumn, $ link);
$link = str_replace('topic/' . $topic->$column , $topic->$column, $link); $ link = str_replace ( 'Ämne /'. $ topic-> $ kolumn, $ topic-> $ kolumn, $ link);
} )

return $link.”/” ; // Very important line! return $ link. "/" / / Very important line! // 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 ) { funktion 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-" av regex när strängen börjar med "bb-" eller "my-" eller är ett reserverat ord
return preg_replace('/^(my-.*|bb-.*|rss|tags|view|profiles)$/', 'r-$1′, $text_slug); return preg_replace ('/^( min-.* | bb-.* | RSS | Taggar | view | profiler )$/', "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 fil:

( Taken from one same forum link and modified a little. You will need to remove the MULTIVIEW from your existing .htaccess file ) (Utdrag ur en och samma forum länk och ändrat lite. Du måste ta bort MultiView från din befintliga. Htaccess-fil)

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

Options +FollowSymlinks Alt + FollowSymLinks

RewriteRule ^tags/([^/]+)/page/([0-9]+)/?$ tags.php?tag=$1&page=$2 [L,QSA] RewriteRule ^ tags /([^/]+)/ sida / ([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] RewriteRule ^ profil /([^/]+)/ sida / ([0-9 ]+)/?$ profile.php? Id = $ 1 & page = $ 2 [L, QSA]
RewriteRule ^profile/([^/]+)/([^/]+)/?$ profile.php?id=$1&tab=$2 [L,QSA] RewriteRule ^ profil /([^/]+)/([^/]+)/?$ profile.php? Id = $ 1 & tab = $ 2 [L, QSA]
RewriteRule ^profile/([^/]+)/([^/]+)/page/([0-9]+)/?$ profile.php?id=$1&tab=$2&page=$3 [L,QSA] RewriteRule ^ profil /([^/]+)/([^/]+)/ sida / ([0-9 ]+)/?$ profile.php? Id = $ 1 & tab = $ 2 & page = $ 3 [L, QSA ]
RewriteRule ^profile/([^/]+)/?$ profile.php?id=$1 [L,QSA] RewriteRule ^ profil /([^/]+)/?$ profile.php? Id = $ 1 [L, QSA]
RewriteRule ^view/([^/]+)/page/([0-9]+)/?$ view.php?view=$1&page=$2 [L,QSA] RewriteRule ^ view /([^/]+)/ sida / ([0-9 ]+)/?$ view.php? View = $ 1 & page = $ 2 [L, QSA]
RewriteRule ^view/([^/]+)/?$ view.php?view=$1 [L,QSA] RewriteRule ^ view /([^/]+)/?$ 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 / topic /([^/]+)/?$ 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] RewriteRule ^ rss / profil /([^/]+)/?$ rss.php? Profile = $ 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. Placera plugin fil i min-plugin katalog och. Htaccess-fil i bbPress rotkatalog. Active the plugin. Aktiv insticksprogrammet. and it should work fine. och det bör fungera bra.

The Problem I find with this. Det problem jag finner med detta.

  • The Link to BBpress admin board link does not work from main site. Länka till bbPress admin board Länken fungerar inte från huvudsida. It redirects to home page. Den vidarebefordras till hemsidan. You will need to manually type the link to go inside. Du måste manuellt skriva in länken för att komma in.
  • 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 . I fall du skriver något som inte existerar som http://sitename.com/ <bbpress-directory> / sdaksda det återgår http://sitename.com/ <bbpress-directory> / /. An extra snedstreck.

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. Utom dessa 2 är det inga problem jag ser så långt men inte lätt att förutsäga eftersom jag dont har många inlägg eller användare. So if you want to try it out Så om du vill prova det download the files here ladda ner filerna här . . You can give your feedback here if you can improve it. Du kan ge din feedback här om du kan förbättra det. And If somebody wants they can support the plugin and enhance it. Och om någon vill kan stödja plugin och förbättra den. You can see Du kan se demo of this on the forum demo av detta på forumet I tested on but You wont be able to register and anyways it just a test forum Jag testade på men Du kommer inte att kunna registrera och anyways det bara en test forum

Tagged with: Märkta med: | Need more help ? | Behöver du mer hjälp? Ask your Questions at our Ställ dina frågor på vår Support Center Supportcenter | Follow us on Twitter | Följ med oss på Twitter @TSNW @ TSNW or eller Facebook Facebook
Facebook DelaPrint 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 Inlagd den 4 april 2008 av Ashish Mohta Ashish Mohta , A tech blogger who writes about solving day to day problems of people who use computer. A tech bloggare som skriver om att lösa dagliga problem för människor som använder datorn. He also writes on How to use the applications like Office, PC tips, Online tools,Browsers and more. All posts by Han skriver också om hur du använder programmen som Office, PC tips, online-verktyg, webbläsare med mera. Alla inlägg av Ashish Mohta Ashish Mohta | Connect with me @ | Anslut med mig @ Twitter Twitter | | Linkedin LinkedIn | | Facebook Facebook | | Stumble Stumble

One Comment En Kommentar » »

  • Tommie said: Tommie sa

    Thanks! Tack! It works wonders. Det fungerar fantastiskt. Running it now on the community site Callofduty.se. Köra det nu på community site Callofduty.se. Your sh*t is the only EASY solution to this problem – thanks again! Din sh * t är den enda enkel lösning på problemet - tack igen!

    (Running it with bbPress 1.01 if anyone would like to know) (Running det med bbPress 1,01 om någon vill veta)

Leave your response! Lämna ditt svar!

Be nice. Be nice. Keep it clean. Keep it clean. Stay on topic. Håll dig till ämnet. No spam. Ingen spam.