Home Inici » » Blog Tips Bloc Tips

How to remove forum and topic keyword from bbpress url Com eliminar fòrum i la paraula clau tema de l'URL BBPress

I had been trying lot of forum softwares ( around 5 till now ) from last Friday and was testing BBPRESS yesterday. Jo havia estat tractant molt de softwares fòrum (al voltant de 5 fins ara) des de divendres passat i estava provant BBPress ahir. The new version9.x has lot of improvement over its 8.x version but one thing I found common in both of them El nou version9.x ha millorat molt en la seva versió 8.x, però he trobat una cosa comuna en ambdós

  • “Forum” keyword was appended when you accesss any forum eg http://sitename.com/<forum-directory>/ forum /<forum slug> "Forum" de paraules clau es va adjuntar al Accesss per exemple, qualsevol fòrum http://sitename.com/ <forum-directory> / / fòrum <Fòrum slug>
  • “topic” keyword was also appended for every post made eg http://sitename.com<forum-directory>/ topic /<actualy topic slug> "" Tema clau ser que també s'edita en totes les entrades fetes per exemple, http://sitename.com <forum-directory> / / tema <actualy tema 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. Ara entenc per què tant les paraules clau són reqired però de nou des del punt de SEO no té sentit a menys que algú executa un fòrum sobre "fòrums" tema. The next thing I did was look around for a hack and luckily El següent que va fer va ser mirar al seu voltant per a un hack i per sort at this post there was a solution en aquest lloc hi havia una solució , but not actual plugin was supported. , Però no va comptar amb el suport plugin real. I copied the code given there and tested around and was successful. He copiat el codi que s'hagi provat i tornada i va ser un èxit.

Before I start, I have just tested around with the code given by the memebers over there. Abans de començar, he provat només amb el codi donat pel memebers allà. So test it before you use it. Així que provar-ho abans d'usar-lo. And moreover I am not supporting it as I did not make it and cant do it either. I a més jo no estic donant suport com jo no vaig fer i no puc fer tampoc.

I made a plugin from the code given and took re-write code for .htaccess files. Vaig fer un plugin des del codi indicat i es re-escriure el codi dels fitxers. Htaccess. Here is how they look Aquí és com es veuen

PLUGIN:( Taken from the forum link ) PLUGIN: (Pres de l'enllaç del fòrum)

<?php De SPAM
/* / *
Plugin Name: Remove Topic Forum Nom del Plugin: Eliminar tema del Fòrum
Plugin URI: http://bbpress.org/ Plugin URI: http://bbpress.org/
Description: Allows to remove forum and topic word in url Descripció: Permet eliminar fòrum i la paraula tema en l'URL
Author: Ashish Mohta Autor: Ashish Mohta
Version: 1.0 Versió: 1.0
Author URI: http://www.technospot.net/blogs/ Author URI: http://www.technospot.net/blogs/
*/ * /

function my_get_forum_link_filter( $link , $forum_id = 0 ) { my_get_forum_link_filter funció ($ link, $ forum_id = 0) (
//retrieve the forum object / / Recuperar l'objecte fòrum
$forum = get_forum( get_forum_id( $forum_id )); fòrum $ = get_forum (get_forum_id ($ forum_id));

//check for rewrite / / Check for reescriure
$rewrite = bb_get_option( 'mod_rewrite' ); $ Reescriure = bb_get_option ( 'mod_rewrite');
if ( $rewrite ) { if ($ reescriure) (
//what kind of rewrite there is? / / Quin tipus de reescriure el que hi ha? slug use “forum_slug” column, else the column is “forum_id” ús llimac "forum_slug columna, en cas contrari la columna és" forum_id "
$column = ($rewrite === 'slugs')?('forum_slug'):('forum_id'); $ Columna = ($ reescriure === 'llimacs')?(' forum_slug'):(' forum_id');

// change /forum/pets-discussions in /pets-discussions / / / Canvi / Fòrum mascotes-debats en / mascotes debats
// this work only if the rewrite module is modded! / / Això només funcionarà si el mòdul és reescriure modded!
// and this work only if the slugged name will NEVER / / I aquest treball només si el nom colpejat MAI
// be a reserved word like “rss” or “bb-images” / / Ser una paraula reservada, com "RSS" o "BB-imatges"
// and this is achieved by a filter on bb_slug_sanitize / / I això s'aconsegueix mitjançant un filtre en bb_slug_sanitize
$link = str_replace('forum/' . $forum->$column , $forum->$column, $link); $ Link = str_replace ( 'fòrum /'. $ Fòrum-> columna, $ fòrum-> columna, $ enllaç);
} )
return $link.”/”; // Very important line! return $ link ."/"; / / línia molt important! // Added extra slash :Ashish / / Barra extra que es va afegir: 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) { my_get_topic_link_filter funció ($ link, $ topic_id = 0) (
//retrieve the topic object / / Recuperar l'objecte tema
$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 / / Recuperar l'objecte fòrum que és el contenidor tema
$forum = get_forum( get_forum_id( $topic->forum_id )); Fòrum de $ topic = get_forum (get_forum_id ($ -> forum_id));

//check for rewrite / / Check for reescriure
$rewrite = bb_get_option( 'mod_rewrite' ); $ Reescriure = bb_get_option ( 'mod_rewrite');
if ( $rewrite ) { if ($ reescriure) (
//what kind of rewrite there is? / / Quin tipus de reescriure el que hi ha? slug use “forum_slug” column, else the column is “forum_id” ús llimac "forum_slug columna, en cas contrari la columna és" forum_id "
$column = ($rewrite === 'slugs')?('forum_slug'):('forum_id'); $ Columna = ($ reescriure === 'llimacs')?(' forum_slug'):(' forum_id');

//create the “forum/pets-discussions” chunk to show the hierarchical relation forum->topic / / Crear el "fòrum / mascotes-debats" tros de mostrar el fòrum relació jeràrquica-> tema
$forum_nice_uri = “forum/” . forum_nice_uri $ = "fòrum /". $forum->$column . $ Fòrum-> $ columna. “/”; "/";

//attach the hierarchical chunk to the link / / Adjuntar el tros a la relació jeràrquica
$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 $, $ enllaç);

// change /forum/pets-discussions/topic/my-sweet-dog in /pets-discussions/my-sweet-dog / / / Canvi / Fòrum mascotes discussions / temes / mi-dolça-gos / pets-discussions/my-sweet-dog
// this work only if the rewrite module is modded! / / Això només funcionarà si el mòdul és reescriure modded!
// and this work only if the slugged name will NEVER / / I aquest treball només si el nom colpejat MAI
// be a reserved word like “rss” or “bb-images” / / Ser una paraula reservada, com "RSS" o "BB-imatges"
// and this is achieved by a filter on bb_slug_sanitize / / I això s'aconsegueix mitjançant un filtre en bb_slug_sanitize
$link = str_replace('forum/' . $forum->$column , $forum->$column, $link); $ Link = str_replace ( 'fòrum /'. $ Fòrum-> columna, $ fòrum-> columna, $ enllaç);
$link = str_replace('topic/' . $topic->$column , $topic->$column, $link); $ Link = str_replace ( 'topic /'. $ Topic-> columna, $ topic-> columna, $ enllaç);
} )

return $link.”/” ; // Very important line! return $ link. "/"; / / línia molt important! // Added Extra Slash :Ashish / / Afegit 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 ) { my_bb_slug_sanitize_filter funció (longitud $ text_slug, $ text_original = ", $ = 0) (
// add “r-” by regex when the string begins with “bb-” or “my-” or is a reserved word / / Add "r" per expressions regulars quan la cadena comença amb "BB-" o "el meu" o és una paraula reservada
return preg_replace('/^(my-.*|bb-.*|rss|tags|view|profiles)$/', 'r-$1′, $text_slug); return preg_replace ('/^( meu-.* |-BB .* | RSS | Etiquetes | Veure | perfils )$/', '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: arxiu. htcaccess:

( Taken from one same forum link and modified a little. You will need to remove the MULTIVIEW from your existing .htaccess file ) (Extret d'un enllaç mateix fòrum i modificat una mica. Vostè haurà d'eliminar l'MultiView del seu arxiu existent. Htaccess)

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

Options +FollowSymlinks Options + FollowSymLinks

RewriteRule ^tags/([^/]+)/page/([0-9]+)/?$ tags.php?tag=$1&page=$2 [L,QSA] RewriteRule ^ tags /([^/]+)/ pàgina / ([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 ^ perfil /([^/]+)/ pàgina / ([0-9 ]+)/?$ profile.php? Id = $ 1 & page = $ 2 [L, QSA]
RewriteRule ^profile/([^/]+)/([^/]+)/?$ profile.php?id=$1&tab=$2 [L,QSA] RewriteRule ^ perfil /([^/]+)/([^/]+)/?$ profile.php? Id = $ 1 & tab = $ 2 [L, QSA]
RewriteRule ^profile/([^/]+)/([^/]+)/page/([0-9]+)/?$ profile.php?id=$1&tab=$2&page=$3 [L,QSA] RewriteRule ^ perfil /([^/]+)/([^/]+)/ pàgina / ([0-9 ]+)/?$ profile.php? Id = $ 1 & tab = $ 2 & page = $ 3 [L, QSA, ]
RewriteRule ^profile/([^/]+)/?$ profile.php?id=$1 [L,QSA] RewriteRule ^ perfil /([^/]+)/?$ profile.php? Id = $ 1 [L, QSA]
RewriteRule ^view/([^/]+)/page/([0-9]+)/?$ view.php?view=$1&page=$2 [L,QSA] RewriteRule ^ Veure /([^/]+)/ pàgina / ([0-9 ]+)/?$ view.php? Veure = $ 1 & page = $ 2 [L, QSA]
RewriteRule ^view/([^/]+)/?$ view.php?view=$1 [L,QSA] RewriteRule ^ Veure /([^/]+)/?$ view.php? Veure = $ 1 [L, QSA]
RewriteRule ^rss/?$ rss.php [L,QSA] RewriteRule ^ rss /? $ Rss.php [T, QSA]
RewriteRule ^rss/forum/([^/]+)/?$ rss.php?forum=$1 [L,QSA] RewriteRule ^ RSS / fòrum /([^/]+)/?$ rss.php? Fòrum = $ 1 [L, QSA]
RewriteRule ^rss/topic/([^/]+)/?$ rss.php?topic=$1 [L,QSA] RewriteRule ^ RSS / tema /([^/]+)/?$ 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 / perfil /([^/]+)/?$ rss.php? Perfil = $ 1 [L, QSA]

RewriteRule ^([^.]+)/([^.]+)/page/([0-9]+)/?$ topic.php?id=$2&page=$3 [L,QSA] RewriteRule ^([^.]+)/([^.]+)/ pàgina / ([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 ^([^/.]+)/ pàgina / ([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. Col loqueu el fitxer al directori de plug-in my-plugin i arxiu. Htaccess al directori arrel bbPress. Active the plugin. Active el plugin. and it should work fine. i hauria de funcionar bé.

The Problem I find with this. El problema que trobem amb això.

  • The Link to BBpress admin board link does not work from main site. L'enllaç amb consells d'administració a administració BBPress no funciona des del lloc principal. It redirects to home page. Redirecciona a la pàgina d'inici. You will need to manually type the link to go inside. Vostè haurà d'escriure manualment l'enllaç per anar al seu interior.
  • 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 . En cas que escrigui alguna cosa que no existeix com http://sitename.com/ <bbpress-directory> / sdaksda torna http://sitename.com/ <bbpress-directory> / /. Una barra addicional.

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. Excepte aquests 2 no hi ha problema que veig fins ara però no és fàcil de predir, com no tinc molt dels llocs o els usuaris. So if you want to try it out Així que si vols provar-ho download the files here els arxius de descàrrega aquí . . You can give your feedback here if you can improve it. Vostè pot donar la seva opinió aquí si es pot millorar. And If somebody wants they can support the plugin and enhance it. I si algú vol que puguin recolzar el plugin i millorar-lo. You can see Vostè pot veure demo of this on the forum demostració d'això en el fòrum de I tested on but You wont be able to register and anyways it just a test forum He provat en vostè, però no serà capaç de registrar i de totes maneres és només un fòrum de prova

Tagged with: Etiquetatge amb: | Need more help ? | Necessiteu més ajuda? Ask your Questions at our Formula les teves preguntes al nostre Support Center Centre de Suport | Follow us on Twitter | Siga amb nosaltres a Twitter @TSNW @ TSNW or o Facebook Facebook
Comparteix a FacebookPrint 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 Publicat el 4 d'abril de 2008 per Ashish Mohta Ashish Mohta , A Professional Tech blogger, Editor and Writer who talks about solving day to day problems of people who use computer. , Un blogger professional Tech, editor i escriptor que parla sobre la solució de problemes quotidians de les persones que utilitzen l'ordinador. He also writes on How to use the applications like Office, PC tips, Online tools,Browsers and more. All posts by Ell també escriu sobre com utilitzar les aplicacions com Office, PC consells, eines en línia, Navegadors i molt més. Tots els llocs de Ashish Mohta Ashish Mohta | Connect with me @ | Connectar amb mi @ Twitter Twitter | | Linkedin Linkedin | | Facebook Facebook | | Stumble Stumble

One Comment Un comentari » »

  • Tommie said: Tommie va dir:

    Thanks! Gràcies! It works wonders. Funciona de meravelles. Running it now on the community site Callofduty.se. Executant ara en el lloc de la comunitat Callofduty.se. Your sh*t is the only EASY solution to this problem – thanks again! La teva merda és l'única solució fàcil a aquest problema - gràcies una altra vegada!

    (Running it with bbPress 1.01 if anyone would like to know) (Corrent amb bbPress 1,01 si algú vol saber)

Leave your response! Deixi la seva resposta!

Be nice. Sigues amable. Keep it clean. Mantenir net. Stay on topic. Manténgase sobre el tema. No spam. No spam.