Home Будинок » » Blog Tips Блог Поради

How to remove forum and topic keyword from bbpress url Як видалити тему форуму та ключові слова з URL bbpress

I had been trying lot of forum softwares ( around 5 till now ) from last Friday and was testing BBPRESS yesterday. Я намагався багато форумі програмного забезпечення (близько 5 до сих пор) з минулої п'ятниці, і тестування BBPRESS вчора. The new version9.x has lot of improvement over its 8.x version but one thing I found common in both of them У новому version9.x має багато поліпшень порівняно 8.x свою версію, але одну річ я знайшов поширення в обидва

  • “Forum” keyword was appended when you accesss any forum eg http://sitename.com/<forum-directory>/ forum /<forum slug> "Форум" ключове слово було докладено при accesss будь-який форум наприклад http://sitename.com/ <forum-directory> / форум / <forum slug>
  • “topic” keyword was also appended for every post made eg http://sitename.com<forum-directory>/ topic /<actualy topic slug> "Тема" ключове слово було також докладено для кожного поста зробив наприклад http://sitename.com <forum-directory> / теми / <actualy теми 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. Тепер я розумію, чому так слова reqired но опять від SEO момент не має сенсу, якщо хтось працює форум, на "форуми" тема. The next thing I did was look around for a hack and luckily Наступне, що я був оглянути для хака і до щастя at this post there was a solution на цій посаді було врегулювання , but not actual plugin was supported. , Але не фактичні плагіна була підтримана. I copied the code given there and tested around and was successful. Я скопіювали код, зазначений у цій країні та навколо та тестування пройшло успішно.

Before I start, I have just tested around with the code given by the memebers over there. Перш ніж почати, я тільки тестування приблизно в код, вказаний на memebers там. So test it before you use it. Тому перевірити, перш ніж використовувати його. And moreover I am not supporting it as I did not make it and cant do it either. І крім того, я не підтримати його, як я не зробив це, і нахиляє зробити.

I made a plugin from the code given and took re-write code for .htaccess files. Я зробив плагін з урахуванням коду і прийняв знову писати код. Htaccess файлів. Here is how they look Ось як вони виглядають

PLUGIN:( Taken from the forum link ) PlugIn: (почерпнути з форуму посилання)

<?php <? PHP
/* / *
Plugin Name: Remove Topic Forum Назва плагіна: видалення Тема форуму
Plugin URI: http://bbpress.org/ Плагін URI: http://bbpress.org/
Description: Allows to remove forum and topic word in url Опис: Дозволяє видалити форуму і теми слова в URL
Author: Ashish Mohta Автор: Ashish Mohta
Version: 1.0 Версія: 1.0
Author URI: http://www.technospot.net/blogs/ Автор URI: http://www.technospot.net/blogs/
*/ * /

function my_get_forum_link_filter( $link , $forum_id = 0 ) { Функція my_get_forum_link_filter ($ посиланням, $ forum_id = 0) (
//retrieve the forum object / / Отримати Форум об'єкта
$forum = get_forum( get_forum_id( $forum_id )); $ = Get_forum форум (get_forum_id ($ forum_id));

//check for rewrite / / Перевірка переписати
$rewrite = bb_get_option( 'mod_rewrite' ); $ Переписати = bb_get_option ( 'mod_rewrite');
if ( $rewrite ) { якщо ($ перезапису) (
//what kind of rewrite there is? / / Какие переписати є? slug use “forum_slug” column, else the column is “forum_id” слізень використання "forum_slug" стовпець, інакше стовпчик "forum_id"
$column = ($rewrite === 'slugs')?('forum_slug'):('forum_id'); $ Колонка = ($ переписати === 'slugs')?(' forum_slug'):(' forum_id');

// change /forum/pets-discussions in /pets-discussions / / Зміна / форум / тварини дискусій в / тварини дискусій
// this work only if the rewrite module is modded! / / Цю роботу тільки в тому випадку, якщо переписати модуль modded!
// and this work only if the slugged name will NEVER / / І цю роботу тільки в тому випадку, якщо slugged ім'я НИКОГДА
// be a reserved word like “rss” or “bb-images” / / Бути захищені слова, як "RSS" або "BB-зображень"
// and this is achieved by a filter on bb_slug_sanitize / / І це досягається за допомогою фільтра на bb_slug_sanitize
$link = str_replace('forum/' . $forum->$column , $forum->$column, $link); $ Посиланням = str_replace ( 'форум /'. $-Форум> $ колонці $-форум> $ колонка, $ Link);
} )
return $link.”/”; // Very important line! повернути $ посилання ."/"; / / Дуже важливо лінія! // Added extra slash :Ashish / / Додана додаткова риса: 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 ($ посиланням, $ topic_id = 0) (
//retrieve the topic object / / Отримати темою об'єкт
$topic = get_topic( get_topic_id( $topic_id )); $ = Get_topic тему (get_topic_id ($ topic_id));

//retrieve the forum object that is the topic container / / Отримати форуму об'єкт, який є темою контейнер
$forum = get_forum( get_forum_id( $topic->forum_id )); $ = Get_forum форум (get_forum_id ($ теми> forum_id));

//check for rewrite / / Перевірка переписати
$rewrite = bb_get_option( 'mod_rewrite' ); $ Переписати = bb_get_option ( 'mod_rewrite');
if ( $rewrite ) { якщо ($ перезапису) (
//what kind of rewrite there is? / / Какие переписати є? slug use “forum_slug” column, else the column is “forum_id” слізень використання "forum_slug" стовпець, інакше стовпчик "forum_id"
$column = ($rewrite === 'slugs')?('forum_slug'):('forum_id'); $ Колонка = ($ переписати === 'slugs')?(' forum_slug'):(' forum_id');

//create the “forum/pets-discussions” chunk to show the hierarchical relation forum->topic / / Створити "форум / тварини дискусій" шматок показати ієрархічні відносини форум-> теми
$forum_nice_uri = “forum/” . $ Forum_nice_uri = "форуму /". $forum->$column . $-форум> $ колонка. “/”; "/";

//attach the hierarchical chunk to the link / / Прикріпити ієрархічний шматок на зв'язок
$link = str_replace(bb_get_option('uri'), bb_get_option('uri') . $forum_nice_uri, $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 / / Зміна / форум / тварини дискусій / теми / My-солодким собак в / pets-discussions/my-sweet-dog
// this work only if the rewrite module is modded! / / Цю роботу тільки в тому випадку, якщо переписати модуль modded!
// and this work only if the slugged name will NEVER / / І цю роботу тільки в тому випадку, якщо slugged ім'я НИКОГДА
// be a reserved word like “rss” or “bb-images” / / Бути захищені слова, як "RSS" або "BB-зображень"
// and this is achieved by a filter on bb_slug_sanitize / / І це досягається за допомогою фільтра на bb_slug_sanitize
$link = str_replace('forum/' . $forum->$column , $forum->$column, $link); $ Посиланням = str_replace ( 'форум /'. $-Форум> $ колонці $-форум> $ колонка, $ Link);
$link = str_replace('topic/' . $topic->$column , $topic->$column, $link); $ Посиланням = str_replace ( 'Тема /'. $ Теми> $ колонка, $ теми> $ колонка, $ Link);
} )

return $link.”/” ; // Very important line! повернути $ посиланням. "/" / / Дуже важливо лінія! // Added Extra Slash :Ashish / / Додаткові Подсечно Додано: 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 ($ text_slug, $ text_original = ", $ довжина = 0) (
// add “r-” by regex when the string begins with “bb-” or “my-” or is a reserved word / / Додати "R" на Regex коли рядок починається з "BB-" або "моя-" або є зарезервований словом
return preg_replace('/^(my-.*|bb-.*|rss|tags|view|profiles)$/', 'r-$1′, $text_slug); повернутися preg_replace ('/^(- моему .* | BB-.* | RSS | Теги | Перегляд | профілі )$/', '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 файлу:

( Taken from one same forum link and modified a little. You will need to remove the MULTIVIEW from your existing .htaccess file ) (Почерпнути з однієї ж форумі посилання і трохи змінена. Вам потрібно буде видалити MULTIVIEW з існуючих. Htaccess фото)

<IfModule mod_rewrite.c> <IfModule Mod_rewrite.c>
RewriteEngine On На RewriteEngine
RewriteBase /forums RewriteBase / форуми

Options +FollowSymlinks Функції + FollowSymlinks

RewriteRule ^tags/([^/]+)/page/([0-9]+)/?$ tags.php?tag=$1&page=$2 [L,QSA] RewriteRule ^ теги /([^/]+)/ сторінка / ([0-9 ]+)/?$ tags.php? Тег = $ 1 І сторінка = $ 2 [L, QSA]
RewriteRule ^tags/([^/]+)/?$ tags.php?tag=$1 [L,QSA] RewriteRule ^ теги /([^/]+)/?$ tags.php? Тег = $ 1 [L, QSA]
RewriteRule ^tags/?$ tags.php [L,QSA] RewriteRule ^ теги /? $ Tags.php [L, QSA]
RewriteRule ^profile/([^/]+)/page/([0-9]+)/?$ profile.php?id=$1&page=$2 [L,QSA] RewriteRule ^ профілю /([^/]+)/ сторінка / ([0-9 ]+)/?$ profile.php? ID = $ 1 І сторінка = $ 2 [L, QSA]
RewriteRule ^profile/([^/]+)/([^/]+)/?$ profile.php?id=$1&tab=$2 [L,QSA] RewriteRule ^ профілю /([^/]+)/([^/]+)/?$ profile.php? ID = $ 1 І вкладка = $ 2 [L, QSA]
RewriteRule ^profile/([^/]+)/([^/]+)/page/([0-9]+)/?$ profile.php?id=$1&tab=$2&page=$3 [L,QSA] RewriteRule ^ профілю /([^/]+)/([^/]+)/ сторінка / ([0-9 ]+)/?$ profile.php? ID = $ 1 І вкладка = $ 2 І сторінка = $ 3 [L, QSA ]
RewriteRule ^profile/([^/]+)/?$ profile.php?id=$1 [L,QSA] RewriteRule ^ профілю /([^/]+)/?$ profile.php? ID = $ 1 [L, QSA]
RewriteRule ^view/([^/]+)/page/([0-9]+)/?$ view.php?view=$1&page=$2 [L,QSA] RewriteRule ^ думку /([^/]+)/ сторінка / ([0-9 ]+)/?$ view.php? Думка = $ 1 І сторінка = $ 2 [L, QSA]
RewriteRule ^view/([^/]+)/?$ view.php?view=$1 [L,QSA] RewriteRule ^ думку /([^/]+)/?$ view.php? Думка = $ 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 / форум /([^/]+)/?$ rss.php? Форуму = $ 1 [L, QSA]
RewriteRule ^rss/topic/([^/]+)/?$ rss.php?topic=$1 [L,QSA] RewriteRule ^ RSS / теми /([^/]+)/?$ rss.php? Тема = $ 1 [L, QSA]
RewriteRule ^rss/tags/([^/]+)/?$ rss.php?tag=$1 [L,QSA] RewriteRule ^ RSS / теги /([^/]+)/?$ rss.php? Тег = $ 1 [L, QSA]
RewriteRule ^rss/profile/([^/]+)/?$ rss.php?profile=$1 [L,QSA] RewriteRule ^ RSS / Профіль /([^/]+)/?$ rss.php? Профіль = $ 1 [L, QSA]

RewriteRule ^([^.]+)/([^.]+)/page/([0-9]+)/?$ topic.php?id=$2&page=$3 [L,QSA] RewriteRule ^([^.]+)/([^.]+)/ сторінка / ([0-9 ]+)/?$ topic.php? ID = $ 2 І сторінка = $ 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 ^([^/.]+)/ сторінка / ([0-9 ]+)/?$ forum.php? ID = $ 1 І сторінка = $ 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. Покладіть файл плагина в моєму плагін-каталог і. Htaccess файл у кореневому каталозі bbpress. Active the plugin. Активний плагін. and it should work fine. і він повинен працювати добре.

The Problem I find with this. Проблема Я знаходжу в цьому.

  • The Link to BBpress admin board link does not work from main site. Зв'язок з адміністратором BBpress борту посилання не працює з основним сайтом. It redirects to home page. Він перенаправляє на головну сторінку. You will need to manually type the link to go inside. Вам необхідно вручну ввести посилання йти всередину.
  • 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 . У випадку, якщо ви що-то, який не існує в http://sitename.com/ <bbpress-directory> / sdaksda вона повертає http://sitename.com/ <bbpress-directory> / /. Додаткова слеш.

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. За винятком цих 2 немає ніяких проблем я бачу до сих пір, але його не легко передбачити, як я Dont мають велику кількість повідомлень чи користувачів. So if you want to try it out Так що якщо ви хочете спробувати його download the files here завантажити фото тут . . You can give your feedback here if you can improve it. Ви можете дати свій відгук, якщо її можна поліпшити. And If somebody wants they can support the plugin and enhance it. И если кто-то хочет вони можуть підтримувати плагіни і розширювати його. You can see Ви можете бачити demo of this on the forum Демонстрація цього на форумі I tested on but You wont be able to register and anyways it just a test forum Я перевіряв, але зазвичай Ви зможете зареєструватися та будь-якому випадку це просто тест форуму

Tagged with: З тегами: | Need more help ? | Потрібна допомога? Ask your Questions at our Задайте свої питання на нашому Support Center Центр підтримки | Follow us on Twitter | Слідуйте за нами по щебетати @TSNW @ TSNW or або Facebook Facebook
SMS підписка 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 Опубліковано 4 квітня 2008 року Ashish Mohta Ashish Mohta , A tech blogger who writes about solving day to day problems of people who use computer. , А тек блогери, який пише про вирішення повсякденних проблем людей, які використовують комп'ютер. He also writes on How to use the applications like Office, PC tips, Online tools,Browsers and more. All posts by Крім того, він пише про те, як використовувати у програмах, як управління, PC поради, онлайн інструменти, браузери та багато чого іншого. Всі посади Ashish Mohta Ashish Mohta | Connect with me @ | Зв'язатися зі мною @ Twitter Щебетати | | Linkedin LinkedIn | | Facebook Facebook | | Stumble Stumble

One Comment Один коментар » »

  • Tommie said: Томмі сказав:

    Thanks! Спасибо! It works wonders. Він творить чудеса. Running it now on the community site Callofduty.se. Запуск її в даний час на сайті Callofduty.se спільноти. Your sh*t is the only EASY solution to this problem – thanks again! Ваш ш * т це тільки просте рішення цієї проблеми - Ще раз спасибі!

    (Running it with bbPress 1.01 if anyone would like to know) (Запустивши його з bbPress 1.01 Якщо хтось хотів би знати)

Leave your response! Залиште свій відгук!

Be nice. Бути красивим. Keep it clean. Тримайте його в чистоті. Stay on topic. Перебування на темі. No spam. Не спам.

Ім'я