Home Mājas » » Blog Tips Blog Tips

How to remove forum and topic keyword from bbpress url Kā noņemt forumu un tematu atslēgvārdam no bbpress url

I had been trying lot of forum softwares ( around 5 till now ) from last Friday and was testing BBPRESS yesterday. Biju mēģinājis daudz forumu programmatūrām (apmēram 5 līdz šim) no pagājušajā piektdienā, un to pārbaude BBPRESS vakar. The new version9.x has lot of improvement over its 8.x version but one thing I found common in both of them Jauns version9.x ir daudz uzlabojumu pār 8.x versija, bet viena lieta man atrast kopīgu abās no tām

  • “Forum” keyword was appended when you accesss any forum eg http://sitename.com/<forum-directory>/ forum /<forum slug> "Forum" atslēgvārdu bija pievienota, kad jūs nepieejami jebkurā forums piemēram http://sitename.com/ <forum-directory> / Forums / <forum slug>
  • “topic” keyword was also appended for every post made eg http://sitename.com<forum-directory>/ topic /<actualy topic slug> "Temats" atslēgvārdu tika pievienots katram amats kļūst piemēram http://sitename.com <forum-directory> / topic / <actualy topic 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. Tagad es saprotu, kāpēc gan atslēgvārdi reqired bet atkal no SEO punkts tai nav nozīmes, ja kāds darbojas foruma "Forums" tēmu. The next thing I did was look around for a hack and luckily Nākamā lieta, ko es tomēr bija paskatīties uz sacirst un laimi at this post there was a solution Šajā amatā bija risinājums , but not actual plugin was supported. , Bet faktiskais spraudni tika atbalstīts. I copied the code given there and tested around and was successful. Es nokopēt kodu, kas tur un testē apkārt un bija veiksmīga.

Before I start, I have just tested around with the code given by the memebers over there. Pirms es sāku, man ir tikai pārbaudīti aptuveni ar kodu, ko tur memebers. So test it before you use it. Tātad, tests, pirms jums to lietot. And moreover I am not supporting it as I did not make it and cant do it either. Un turklāt es neesmu atbalstītu to kā man nebija darīt to un aprunāt darīt, vai nu.

I made a plugin from the code given and took re-write code for .htaccess files. Es spraudnis no kodu, un ņēma jāpārraksta kods. Htaccess failiem. Here is how they look Te tiek kā viņi izskatās

PLUGIN:( Taken from the forum link ) Plugin: (Ņemts no foruma saite)

<?php <? php
/* / *
Plugin Name: Remove Topic Forum Plugin Name: Remove Topic Forums
Plugin URI: http://bbpress.org/ Plugin URI: http://bbpress.org/
Description: Allows to remove forum and topic word in url Apraksts: Ļauj, lai novērstu forumu un tematu vārds url
Author: Ashish Mohta Autors: Ashish Mohta
Version: 1.0 Versija: 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 ) { funkcija my_get_forum_link_filter ($ link, $ forum_id = 0) (
//retrieve the forum object / / ielādētu forums objekts
$forum = get_forum( get_forum_id( $forum_id )); $ forums = get_forum (get_forum_id ($ forum_id));

//check for rewrite / / pārbaudīt pārrakstīt
$rewrite = bb_get_option( 'mod_rewrite' ); $ pārrakstīt = bb_get_option ( "mod_rewrite ');
if ( $rewrite ) { if ($ pārrakstīt) (
//what kind of rewrite there is? / / kāda veida pārrakstīt tur ir? slug use “forum_slug” column, else the column is “forum_id” lode izmantot "forum_slug" ailē, cits ailē ir "forum_id"
$column = ($rewrite === 'slugs')?('forum_slug'):('forum_id'); $ kolonna = ($ pārrakstīt === 'lodes')?(' forum_slug'):(' forum_id');

// change /forum/pets-discussions in /pets-discussions / / Mainīt / Forums / pets-diskusijas / pets, diskusijas
// this work only if the rewrite module is modded! / / Tas darbojas tikai tad, ja pārrakstīt modulis ir modded!
// and this work only if the slugged name will NEVER / / Un tas darbojas tikai tad, ja slugged vārds nekad
// be a reserved word like “rss” or “bb-images” / / Be reserved vārds kā "rss" vai "BB-images"
// and this is achieved by a filter on bb_slug_sanitize / / Un tas tiek panākts ar filtru bb_slug_sanitize
$link = str_replace('forum/' . $forum->$column , $forum->$column, $link); $ link = str_replace ( 'forums /'. $ forums-> $ kolonna, $ forums-> $ kolonna, $ link);
} )
return $link.”/”; // Very important line! return $ link ."/"; / / Very important line! // Added extra slash :Ashish / / Pievienots papildus slīpsvītra: 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) { funkcija my_get_topic_link_filter ($ link, $ topic_id = 0) (
//retrieve the topic object / / ielādētu topic objekts
$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 / / ielādētu forums objekts, kas temats konteiners
$forum = get_forum( get_forum_id( $topic->forum_id )); $ forums = get_forum (get_forum_id ($ topic-> forum_id));

//check for rewrite / / pārbaudīt pārrakstīt
$rewrite = bb_get_option( 'mod_rewrite' ); $ pārrakstīt = bb_get_option ( "mod_rewrite ');
if ( $rewrite ) { if ($ pārrakstīt) (
//what kind of rewrite there is? / / kāda veida pārrakstīt tur ir? slug use “forum_slug” column, else the column is “forum_id” lode izmantot "forum_slug" ailē, cits ailē ir "forum_id"
$column = ($rewrite === 'slugs')?('forum_slug'):('forum_id'); $ kolonna = ($ pārrakstīt === 'lodes')?(' forum_slug'):(' forum_id');

//create the “forum/pets-discussions” chunk to show the hierarchical relation forum->topic / / izveidot "forum / pets-diskusijas" gabalu, lai parādītu hierarhijas attiecības forums-> topic
$forum_nice_uri = “forum/” . $ forum_nice_uri = "forum /". $forum->$column . $ forums-> $ ailē. “/”; "/";

//attach the hierarchical chunk to the link / / pievienot hierarhijas gabalu saite
$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 / / Mainīt / Forums / pets-diskusijas / topic / my-sweet-dog in / pets-discussions/my-sweet-dog
// this work only if the rewrite module is modded! / / Tas darbojas tikai tad, ja pārrakstīt modulis ir modded!
// and this work only if the slugged name will NEVER / / Un šai darbā vienīgi tad, slugged vārds nekad
// be a reserved word like “rss” or “bb-images” / / Be reserved vārds kā "rss" vai "BB-images"
// and this is achieved by a filter on bb_slug_sanitize / / Un tas tiek panākts ar filtru bb_slug_sanitize
$link = str_replace('forum/' . $forum->$column , $forum->$column, $link); $ link = str_replace ( 'forums /'. $ forums-> $ kolonna, $ forums-> $ kolonna, $ link);
$link = str_replace('topic/' . $topic->$column , $topic->$column, $link); $ link = str_replace ( 'topic /'. $ topic-> $ kolonna, $ topic-> $ kolonna, $ link);
} )

return $link.”/” ; // Very important line! return $ saiti. "/"; / / 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 ) { funkcija my_bb_slug_sanitize_filter ($ text_slug, $ text_original = ", $ garums = 0) (
// add “r-” by regex when the string begins with “bb-” or “my-” or is a reserved word / / Add "R" ar regex, kad virkne sākas ar "BB-" vai "mana-" vai ir rezervēts vārds
return preg_replace('/^(my-.*|bb-.*|rss|tags|view|profiles)$/', 'r-$1′, $text_slug); atpakaļ preg_replace ('/^( my-.* | bb-.* | RSS | tags | lauks | profili )$/', "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 failu:

( Taken from one same forum link and modified a little. You will need to remove the MULTIVIEW from your existing .htaccess file ) (Ņemts no viena paša foruma saites un izmaiņas maz. Jums būs nepieciešams, lai novērstu Multiview no sava esošā. Htaccess failu)

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

Options +FollowSymlinks Options + FollowSymlinks

RewriteRule ^tags/([^/]+)/page/([0-9]+)/?$ tags.php?tag=$1&page=$2 [L,QSA] RewriteRule ^ tagi /([^/]+)/ 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] RewriteRule ^ profils /([^/]+)/ page / ([0-9 ]+)/?$ profile.php? Id = $ 1 & page = $ 2 [L, QSA]
RewriteRule ^profile/([^/]+)/([^/]+)/?$ profile.php?id=$1&tab=$2 [L,QSA] RewriteRule ^ profils /([^/]+)/([^/]+)/?$ profile.php? Id = $ 1 & tab = $ 2 [L, QSA]
RewriteRule ^profile/([^/]+)/([^/]+)/page/([0-9]+)/?$ profile.php?id=$1&tab=$2&page=$3 [L,QSA] RewriteRule ^ profils /([^/]+)/([^/]+)/ page / ([0-9 ]+)/?$ profile.php? Id = $ 1 & tab = $ 2 & page = $ 3 [L, QSA ]
RewriteRule ^profile/([^/]+)/?$ profile.php?id=$1 [L,QSA] RewriteRule ^ profils /([^/]+)/?$ profile.php? Id = $ 1 [L, QSA]
RewriteRule ^view/([^/]+)/page/([0-9]+)/?$ view.php?view=$1&page=$2 [L,QSA] RewriteRule ^ viedokli /([^/]+)/ page / ([0-9 ]+)/?$ view.php? Ņemot = $ 1 & page = $ 2 [L, QSA]
RewriteRule ^view/([^/]+)/?$ view.php?view=$1 [L,QSA] RewriteRule ^ viedokli /([^/]+)/?$ view.php? Ņemot = $ 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? Forums = $ 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 / profile /([^/]+)/?$ rss.php? Profils = $ 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. Vieta plugin failu my-spraudnis direktorijā un. Htaccess failu bbpress saknes direktorijā. Active the plugin. Active spraudni. and it should work fine. un tai ir jāstrādā labi.

The Problem I find with this. Problēma man ar to.

  • The Link to BBpress admin board link does not work from main site. Saite uz BBpress admin board saite nedarbojas no galvenajiem vietā. It redirects to home page. Tā novirza uz mājas lapu. You will need to manually type the link to go inside. Jums vajadzēs manuāli tipa saiti iet iekšā.
  • 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 . Ja rakstāt kaut kas neeksistē, kā http://sitename.com/ <bbpress-directory> / sdaksda tāatgriež http://sitename.com/ <bbpress-directory> / /. Extra slīpsvītra.

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. Izņemot šos 2 nav problēmu es redzu, līdz šim, bet tās nav viegli prognozēt, kā es dont ir daudz amatu vai lietotājiem. So if you want to try it out Tātad, ja jūs vēlaties to izmēģināt download the files here lejupielādēt failus šeit . . You can give your feedback here if you can improve it. Jūs varat dot savu atsauksmi šeit, ja jūs varat uzlabot. And If somebody wants they can support the plugin and enhance it. Un, ja kāds vēlas, viņi var atbalstīt spraudnis un uzlabot to. You can see Jūs varat redzēt demo of this on the forum demo šajā forumā I tested on but You wont be able to register and anyways it just a test forum Es testēt, bet Jums mēdz būt iespējai reģistrēties un anyways ir tikai testa forums

Tagged with: Tagged with: | Need more help ? | Vajadzīga palīdzība? Ask your Questions at our Jautājiet pēc mūsu Support Center Support Center | Follow us on Twitter | Follow us on Twitter @TSNW @ TSNW or vai Facebook Facebook
Facebook Share Print 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 Iesūtīts 2008 4 aprīlis by Ashish Mohta Ashish Mohta , A tech blogger who writes about solving day to day problems of people who use computer. , Tech blogeris, kas raksta par risināšanas ikdienas problēmas, cilvēkiem, kuri lieto datoru. He also writes on How to use the applications like Office, PC tips, Online tools,Browsers and more. All posts by Viņš arī raksta par to, kā izmantot kā biroju, PC padomus, tiešsaistes rīkus, pārlūkprogrammas un lietojumprogrammas. Visas ziņas, ko Ashish Mohta Ashish Mohta | Connect with me @ | Sazinieties ar mani @ Twitter Čivināt | | Linkedin LinkedIn | | Facebook Facebook | | Stumble Paklupt

One Comment Viens komentārs » »

  • Tommie said: Tommie teica:

    Thanks! Pateicība! It works wonders. It works brīnumus. Running it now on the community site Callofduty.se. Running tagad uz Vietnes Callofduty.se. Your sh*t is the only EASY solution to this problem – thanks again! Jūsu sh * t ir tikai vienkāršākais risinājums šai problēmai - thanks again!

    (Running it with bbPress 1.01 if anyone would like to know) (Running to ar 1,01 bbPress ja kāds vēlas zināt)

Leave your response! Atstājiet Jūsu reakcijas!

Be nice. Be nice. Keep it clean. Sargàjiet to no tīras. Stay on topic. Paliktu uz tēmu. No spam. Nr surogātpastu.