PunBB is by far the world’s best open source PHP forum. For example, our handcellphone forum is powered by PunBB. To do what handcellphone forum does in SEO by making the urls of your PunBB forum more Search Engine Friendly, you need to add Rewrite Mod into your PunBB forum (download ReWrite Mod).
Follow the instruction below to modify your PunBB codes to make your forum more search engine friendly.
#
#———[ 1. UPLOAD ]——————————————————-
#
.htaccess to /
rewrite.php to /include/
#
#———[ 2. OPEN ]———————————————————
#
include/common.php
#
#———[ 3. FIND (line: 35) ]———————————————
#
// Load the functions script
require PUN_ROOT.’include/functions.php’;
#
#———[ 4. AFTER, ADD ]————————————————-
#
require PUN_ROOT.’include/rewrite.php’;
#
#———[ 5. OPEN ]———————————————————
#
index.php
#
#———[ 6. FIND (line: 100) ]———————————————
#
$forum_field = ‘<h3><a xhref=”viewforum.php?id=’.$cur_forum['fid'].’” mce_href=”viewforum.php?id=’.$cur_forum['fid'].’”>’.pun_htmlspecialchars($cur_forum['forum_name']).’</a></h3>’;
#
#———[ 7. REPLACE WITH ]————————————————-
#
$forum_field = ‘<h3><a xhref=”‘.makeurl(” mce_href=”‘.makeurl(”f”, $cur_forum['fid'], $cur_forum['forum_name']).’”>’.pun_htmlspecialchars($cur_forum['forum_name']).’</a></h3>’;
#
#———[ 6. FIND (line: 111) ]———————————————
#
$last_post = ‘<a xhref=”viewtopic.php?pid=’.$cur_forum['last_post_id'].’#p’.$cur_forum['last_post_id'].’” mce_href=”viewtopic.php?pid=’.$cur_forum['last_post_id'].’#p’.$cur_forum['last_post_id'].’”>’.format_time($cur_forum['last_post']).’</a> <span class=”byuser”>’.$lang_common['by'].’ ‘.pun_htmlspecialchars($cur_forum['last_poster']).’</span>’;
#
#———[ 7. REPLACE WITH ]————————————————-
#
$last_post = ‘<a xhref=”‘.makeurl(” mce_href=”‘.makeurl(”p”, $cur_forum['last_post_id'], format_time($cur_forum['last_post'])).’#p’.$cur_forum['last_post_id'].’”>’.format_time($cur_forum['last_post']).’</a> <span class=”byuser”>’.$lang_common['by'].’ ‘.pun_htmlspecialchars($cur_forum['last_poster']).’</span>’;
#
#———[ 8. OPEN ]———————————————————
#
viewforum.php
#
#———[ 9. FIND (line: 149) ]———————————————
#
$last_post = ‘<a xhref=”viewtopic.php?pid=’.$cur_topic['last_post_id'].’#p’.$cur_topic['last_post_id'].’” mce_href=”viewtopic.php?pid=’.$cur_topic['last_post_id'].’#p’.$cur_topic['last_post_id'].’”>’.format_time($cur_topic['last_post']).’</a> <span class=”byuser”>’.$lang_common['by'].’ ’.pun_htmlspecialchars($cur_topic['last_poster']).’</span>’;
#
#———[ 10. REPLACE WITH ]————————————————-
#
$last_post = ‘<a xhref=”‘.makeurl(” mce_href=”‘.makeurl(”p”, $cur_topic['last_post_id'], format_time($cur_topic['last_post'])).’#p’.$cur_topic['last_post_id'].’”>’.format_time($cur_topic['last_post']).’</a> <span class=”byuser”>’.$lang_common['by'].’ ’.pun_htmlspecialchars($cur_topic['last_poster']).’</span>’;
#
#———[ 11. FIND (line: 195) ]———————————————
#
$subject = $lang_forum['Moved'].’: <a xhref=”viewtopic.php?id=’.$cur_topic['moved_to'].’” mce_href=”viewtopic.php?id=’.$cur_topic['moved_to'].’”>’.pun_htmlspecialchars($cur_topic['subject']).’</a> <span class=”byuser”>’.$lang_common['by'].’ ’.pun_htmlspecialchars($cur_topic['poster']).’</span>’;
#
#———[ 12. REPLACE WITH ]————————————————-
#
$subject = $lang_forum['Moved'].’: <a xhref=”‘.makeurl(” mce_href=”‘.makeurl(”t”, $cur_topic['moved_to'], $cur_topic['subject']).’”>’.pun_htmlspecialchars($cur_topic['subject']).’</a> <span class=”byuser”>’.$lang_common['by'].’ ’.pun_htmlspecialchars($cur_topic['poster']).’</span>’;
#
#———[ 13. FIND (line: 197) ]———————————————
#
$subject = ‘<a xhref=”viewtopic.php?id=’.$cur_topic['id'].’” mce_href=”viewtopic.php?id=’.$cur_topic['id'].’”>’.pun_htmlspecialchars($cur_topic['subject']).’</a> <span class=”byuser”>’.$lang_common['by'].’ ’.pun_htmlspecialchars($cur_topic['poster']).’</span>’;
#
#———[ 14. REPLACE WITH ]————————————————-
#
$subject = ‘<a xhref=”‘.makeurl(” mce_href=”‘.makeurl(”t”, $cur_topic['id'], $cur_topic['subject']).’”>’.pun_htmlspecialchars($cur_topic['subject']).’</a> <span class=”byuser”>’.$lang_common['by'].’ ’.pun_htmlspecialchars($cur_topic['poster']).’</span>’;
#
#———[ 15. FIND (line: 200) ]———————————————
#
$subject = ‘<a xhref=”viewtopic.php?id=’.$cur_topic['id'].’” mce_href=”viewtopic.php?id=’.$cur_topic['id'].’”>’.pun_htmlspecialchars($cur_topic['subject']).’</a> <span class=”byuser”>’.$lang_common['by'].’ ’.pun_htmlspecialchars($cur_topic['poster']).’</span>’;
#
#———[ 16. REPLACE WITH ]————————————————-
#
$subject = ‘<a xhref=”‘.makeurl(” mce_href=”‘.makeurl(”t”, $cur_topic['id'], $cur_topic['subject']).’”>’.pun_htmlspecialchars($cur_topic['subject']).’</a> <span class=”byuser”>’.$lang_common['by'].’ ’.pun_htmlspecialchars($cur_topic['poster']).’</span>’;
#
#———[ 17. OPEN ]———————————————————
#
viewtopic.php
#
#———[ 18. FIND (line: 172) ]———————————————
#
<ul><li><a xhref=”index.php” mce_href=”index.php”><?php echo $lang_common['Index'] ?></a></li><li> » <a xhref=”viewforum.php?id=<?php echo $cur_topic['forum_id'] ?>”><?php echo pun_htmlspecialchars($cur_topic['forum_name']) ?></a></li><li> » <?php echo pun_htmlspecialchars($cur_topic['subject']) ?></li></ul>
#
#———[ 19. REPLACE WITH ]————————————————-
#
<ul><li><a xhref=”index.php” mce_href=”index.php”><?php echo $lang_common['Index'] ?></a></li><li> » <a xhref=”<?php echo makeurl(”f”, $cur_topic['forum_id'], $cur_topic['forum_name']) ?>”><?php echo pun_htmlspecialchars($cur_topic['forum_name']) ?></a></li><li> » <?php echo pun_htmlspecialchars($cur_topic['subject']) ?></li></ul>
#
#———[ 20. FIND (line: 315) ]———————————————
#
<h2><span><span class=”conr”>#<?php echo ($start_from + $post_count) ?> </span><a xhref=”viewtopic.php?pid=<?php echo $cur_post['id'].’#p’.$cur_post['id'] ?>”><?php echo format_time($cur_post['posted']) ?></a></span></h2>
#
#———[ 21. REPLACE WITH ]————————————————-
#
<h2><span><span class=”conr”>#<?php echo ($start_from + $post_count) ?> </span><a xhref=”<?php echo makeurl(”p”, $cur_post['id'], format_time($cur_post['posted'])).’#p’.$cur_post['id'] ?>”><?php echo format_time($cur_post['posted']) ?></a></span></h2>
#
#———[ 22. FIND (line: 351) ]———————————————
#
<ul><li><a xhref=”index.php” mce_href=”index.php”><?php echo $lang_common['Index'] ?></a></li><li> » <a xhref=”viewforum.php?id=<?php echo $cur_topic['forum_id'] ?>”><?php echo pun_htmlspecialchars($cur_topic['forum_name']) ?></a></li><li> » <?php echo pun_htmlspecialchars($cur_topic['subject']) ?></li></ul>
#
#———[ 23. REPLACE WITH ]————————————————-
#
<ul><li><a xhref=”index.php” mce_href=”index.php”><?php echo $lang_common['Index'] ?></a></li><li> » <a xhref=”<?php echo makeurl(”f”, $cur_topic['forum_id'], $cur_topic['forum_name']) ?>”><?php echo pun_htmlspecialchars($cur_topic['forum_name']) ?></a></li><li> » <?php echo pun_htmlspecialchars($cur_topic['subject']) ?></li></ul>
#
#———[ 24. OPEN ]———————————————————
#
search.php
#
#———[ 25. FIND (line: 544) ]———————————————
#
$forum = ‘<a xhref=”viewforum.php?id=’.$temp[0].’” mce_href=”viewforum.php?id=’.$temp[0].’”>’.pun_htmlspecialchars($temp[1]).’</a>’;
#
#———[ 26. REPLACE WITH ]————————————————-
#
$forum = ‘<a xhref=”‘.makeurl(” mce_href=”‘.makeurl(”f”, $temp[0], $temp[1]).’”>’.pun_htmlspecialchars($temp[1]).’</a>’;
#
#———[ 27. FIND (line: 555) ]———————————————
#
$subject = ‘<a xhref=”viewtopic.php?id=’.$search_set[$i]['tid'].’” mce_href=”viewtopic.php?id=’.$search_set[$i]['tid'].’”>’.pun_htmlspecialchars($search_set[$i]['subject']).’</a>’;
#
#———[ 28. REPLACE WITH ]————————————————-
#
$subject = ‘<a xhref=”‘.makeurl(” mce_href=”‘.makeurl(”f”, $search_set[$i]['tid'], $search_set[$i]['subject']).’”>’.pun_htmlspecialchars($search_set[$i]['subject']).’</a>’;
#
#———[ 29. FIND (line: 584) ]———————————————
#
<h2><?php echo $forum ?> » <?php echo $subject ?> » <a xhref=”viewtopic.php?pid=<?php echo $search_set[$i]['pid'].’#p’.$search_set[$i]['pid'] ?>”><?php echo format_time($search_set[$i]['pposted']) ?></a></h2>
#
#———[ 30. REPLACE WITH ]————————————————-
#
<h2><?php echo $forum ?> » <?php echo $subject ?> » <a xhref=”<?php echo makeurl(”p”, $search_set[$i]['pid'], format_time($search_set[$i]['pposted'])).’#p’.$search_set[$i]['pid'] ?>”><?php echo format_time($search_set[$i]['pposted']) ?></a></h2>
#
#———[ 31. FIND (line: 616) ]———————————————
#
$subject = ‘<a xhref=”viewtopic.php?id=’.$search_set[$i]['tid'].’” mce_href=”viewtopic.php?id=’.$search_set[$i]['tid'].’”>’.pun_htmlspecialchars($search_set[$i]['subject']).’</a> <span class=”byuser”>’.$lang_common['by'].’ ’.pun_htmlspecialchars($search_set[$i]['poster']).’</span>’;
#
#———[ 32. REPLACE WITH ]————————————————-
#
$subject = ‘<a xhref=”‘.makeurl(” mce_href=”‘.makeurl(”t”, $search_set[$i]['tid'], $search_set[$i]['subject']).’”>’.pun_htmlspecialchars($search_set[$i]['subject']).’</a> <span class=”byuser”>’.$lang_common['by'].’ ’.pun_htmlspecialchars($search_set[$i]['poster']).’</span>’;
#
#———[ 33. FIND (line: 673) ]———————————————
#
?><td class=”tcr”><?php echo ‘<a xhref=”viewtopic.php?pid=’.$search_set[$i]['last_post_id'].’#p’.$search_set[$i]['last_post_id'].’” mce_href=”viewtopic.php?pid=’.$search_set[$i]['last_post_id'].’#p’.$search_set[$i]['last_post_id'].’”>’.format_time($search_set[$i]['last_post']).’</a> ‘.$lang_common['by'].’ ’.pun_htmlspecialchars($search_set[$i]['last_poster']) ?></td><?php
#
#———[ 34. REPLACE WITH ]————————————————-
#
?><td class=”tcr”><?php echo ‘<a xhref=”‘.makeurl(” mce_href=”‘.makeurl(”p”, $search_set[$i]['last_post_id'], format_time($search_set[$i]['last_post'])).’#p’.$search_set[$i]['last_post_id'].’”>’.format_time($search_set[$i]['last_post']).’</a> ‘.$lang_common['by'].’ ’.pun_htmlspecialchars($search_set[$i]['last_poster']) ?></td><?php
#
#———[ 35. OPEN ]———————————————————
#
extern.php
#
#———[ 36. FIND (line: 126) ]———————————————
#
// Load the functions script
require PUN_ROOT.’include/functions.php’;
#
#———[ 37. AFTER, ADD ]————————————————-
#
require(PUN_ROOT.’include/rewrite.php’);
#
#———[ 38. FIND (line: 255) ]———————————————
#
echo “\t\t”.’<link>’.$pun_config['o_base_url'].’/viewtopic.php?id=’.$cur_topic['id'].$url_action.’</link>’.”\r\n”
#
#———[ 39. REPLACE WITH ]————————————————-
#
echo “\t\t”.’<link>’.$pun_config['o_base_url'].’/’.makeurl(”t”, $cur_topic['id'], $cur_topic['subject']).$url_action.’</link>’.”\r\n”
#
#———[ 40. FIND (line: 227) ]———————————————
#
echo “\t\t”.’<description><![CDATA['.escape_cdata($lang_common['Forum'].’: <a xhref=”‘.$pun_config['o_base_url'].’/viewforum.php?id=’.$cur_topic['fid'].’” mce_href=”‘.$pun_config['o_base_url'].’/viewforum.php?id=’.$cur_topic['fid'].’”>’.$cur_topic['forum_name'].’</a><br />’.”\r\n”.$lang_common['Author'].’: ‘.$cur_topic['poster'].’<br />’.”\r\n”.$lang_common['Posted'].’: ‘.date(’r', $cur_topic['posted']).’<br />’.”\r\n”.$lang_common['Last post'].’: ‘.date(’r', $cur_topic['last_post'])).’]]></description>’.”\r\n”
#
#———[ 41. REPLACE WITH ]————————————————-
#
echo “\t\t”.’<description><![CDATA['.escape_cdata($lang_common['Forum'].’: <a xhref=”‘.$pun_config['o_base_url'].’/’.makeurl(” mce_href=”‘.$pun_config['o_base_url'].’/’.makeurl(”f”, $cur_topic['fid'], $cur_topic['forum_name']).’”>’.$cur_topic['forum_name'].’</a><br />’.”\r\n”.$lang_common['Author'].’: ‘.$cur_topic['poster'].’<br />’.”\r\n”.$lang_common['Posted'].’: ‘.date(’r', $cur_topic['posted']).’<br />’.”\r\n”.$lang_common['Last post'].’: ‘.date(’r', $cur_topic['last_post'])).’]]></description>’.”\r\n”
#
#———[ 42. SAVE/UPLOAD ]————————————————-
#
If your PunBB forum isn’t loaded at the root folder, you have to add RewriteBase /{name of your folder} in the .htaaccess file.
Example:
RewriteEngine on
RewriteBase /techforum
RewriteRule ^f([0-9]+)(.*).html$ viewforum.php?id=$1 [L]
RewriteRule ^t([0-9]+)(.*).html$ viewtopic.php?id=$1 [L]
RewriteRule ^p([0-9]+)(.*).html$ viewtopic.php?pid=$1 [L]
RewriteRule ^(.*).rss$ extern.php?action=$1&type=rss [L]
RewriteRule ^blabla.html$ index.php [L]
If you have any questions, please post them under the comment section below, I will be glad to answer your questions
December 18th, 2007 at 7:25 pm
[...] Plus lots of tools in the wiki, and more forum pages. As you can see, the forum URLs aren’t the best. Getting it merely took a tedious series of cut and paste steps from a tutorial on adminpicks.com Let me just say, punBB is spaghetti and I salute the brave soul who created the patch. Actually, a patch wouldn’t have worked because there’s been some change since then. [...]
December 18th, 2007 at 7:28 pm
[...] Plus lots of tools in the wiki, and more forum pages. As you can see, the forum URLs aren’t the best. Getting it merely took a tedious series of cut and paste steps from a tutorial on adminpicks.com Let me just say, punBB is spaghetti and I salute the brave soul who created the patch. Actually, a patch wouldn’t have worked because there’s been some change since then. [...]
May 22nd, 2008 at 1:57 pm
Wow, thanks for putting up this detailed guide. Real helpful for my Pinoy Entrepreneur forum