SEO for PHPBB 3 - A Checklist Mod for fresh installs
|
|
by
I show you something fantastic and you find fault.
Published on April 24th, 2007, 7:16 pm Rift: Advice |
Here is my running checklist, of SEO for PHPBB 3.0 need on upgrades or new installs.
PHPBB 3.0 is a great forum software, that lack basic fundamental search engine support. I occasionally come back and add or modify these SEO techniques based on current industry standards at the time, so I recommend placing a date stamp somewhere in your PHP files so you can keep track of what version you have installed:
- Code: Select all
// SEO MOD CHECKLIST by Liv Jones - 8/7/2010
Many of the pagination and canonicalization issues have been addressed with the recent introduction of the canonical tag now standard. The last portion of this list deals with a standard phpbb install in a root directory. If you don't wish to use that portion, I recommend adjust the sort_param and possible redirect canonicalization of various pages.... (Be sure to duplicate changes on poll pages too)
If you find any of this useful, please send me some link love in return, as this list took hours of late night time away from my family, and a little respect goes a long way. Thanks...
-Liv
Sessions
Open functions.php
Find:
- Code: Select all
// Assign sid if session id is not specified
if ($session_id === false)
{
$session_id = $_SID;
}
Replace with:
- Code: Select all
// Remove Sessions for guests & bots
if ($session_id === false)
{
$session_id = $_SID;
}
global $user;
if ($user->data['user_id'] == ANONYMOUS OR $user->data['is_bot'] )
{
$session_id = false;
}
// end sessions mod
TITLES & URLS:
Find: (seo urls)
- Code: Select all
'U_INDEX' => append_sid("{$phpbb_root_path}index.$phpEx"),
Replace With
- Code: Select all
// delete the pesky index.php
'U_INDEX' => append_sid("{$phpbb_root_path}"),
// end pesky index
Follow these changes to improve titles:
##############################################################
#
#-----[ OPEN ]------------------------------------------
#
index.php
#
#-----[ FIND ]------------------------------------------
#
page_header($user->lang['INDEX']);
#
#-----[ REPLACE WITH ]------------------------------------------
#
page_header($config['sitename']);
#
#-----[ OPEN ]------------------------------------------
#
viewforum.php
#
#-----[ FIND ]------------------------------------------
#
page_header($user->lang['VIEW_FORUM'] . ' - ' . $forum_data['forum_name']);
#
#-----[ REPLACE WITH ]------------------------------------------
#
page_header($forum_data['forum_name']." - ".$forum_data['forum_desc']);
#
#-----[ OPEN ]------------------------------------------
#
viewtopic.php
#
#-----[ FIND ]------------------------------------------
#
page_header($user->lang['VIEW_TOPIC'] .' - ' . $topic_data['topic_title']);
#
#-----[ REPLACE WITH ]------------------------------------------
#
if ($_GET['start'] > 5) {
$tle=60-strlen($topic_data['topic_title']);
$message=$topic_data['topic_title']." - ".strip_tags(substr($message,0,$tle));
page_header($message);
} else { page_header($topic_data['topic_title']);}
#
#-----[ OPEN ]------------------------------------------
#
styles/subSilver/template/overall_header.html
#
#-----[ FIND ]------------------------------------------
#
<title>{SITENAME} • {PAGE_TITLE}</title>
#
#-----[ REPLACE WITH ]------------------------------------------
#
<title><!-- IF S_IN_MCP -->{L_MCP} • <!-- ELSEIF S_IN_UCP -->{L_UCP} • <!-- ENDIF -->{PAGE_TITLE}</title>
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
HANDLING DELETED POSTS:
This 301 redirect all deleted topics once and for all to the selected URL in PHPBB:
Open viewtopic.php & Find:
- Code: Select all
if (!$topic_data)
{
// If post_id was submitted, we try at least to display the topic as a last resort...
if ($post_id && $forum_id && $topic_id)
{
redirect(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id"));
}
trigger_error('NO_TOPIC');
}
Replace with this:
- Code: Select all
// PHPBB 301 Redirect Modification by Greensboring.com
// Redirects Deleted Posts
// You may need to add the folder to the path follow http_host variable if installed in a subfolder.
if (!$topic_data) {
if ($post_id && $forum_id && $topic_id) {
redirect(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id"));
}
elseif ($forum_id==0 || !isset($forum_id)) {
header("Status: 301 Moved Permanently", true, 301);
header("Location: http://{$_SERVER['HTTP_HOST']}/");
exit();
}
else {
header("Status: 301 Moved Permanently", true, 301);
header("Location: http://{$_SERVER['HTTP_HOST']}/viewforum.{$phpEx}?f={$forum_id}");
exit();
}
}
//EOM
BOTS, SPYDERS, & OTHER CREEPY CRAWLIES
Open Robots.txt (or create)
add:
- Code: Select all
User-agent: *
Disallow: /adm/
Disallow: /download.php
Disallow: /file.php
Disallow: /images/
Disallow: /includes/
Disallow: /language/
Disallow: /memberlist.php
Disallow: /mcp.php
Disallow: /posting.php
Disallow: /ucp.php
Disallow: /search.php
Disallow: /styles/
Disallow: /viewonline.php
Disallow: /faq.php
Disallow: /style.php
Disallow: /style.php*
Disallow: /memberlist.php*
Disallow: /search.php*
Disallow: /ucp.php*
Disallow: /posting.php*
Disallow: /report.php*
Disallow: /download.php*
Disallow: /file.php*
Disallow: /*?sid=*
If Upgrading from a PHPBB 2.0 Board add this mod, otherwise skip:
PHPBB lacks the capability of redirecting PHPBB 2+ style urls to 3.0 style urls, causing canonicalization issues within your site, and search engines. This can easily be overcame by modifying this code. This will 301 redirect any url request for the old 2.0 style urls that do not have the f= tag included to the new url with the f=. A small link of appreciation back to this site would be greatly appreciated if you use this script.
Open Viewtopic.php and find:
- Code: Select all
// We overwrite $_REQUEST['f'] if there is no forum specified
// to be able to display the correct online list.
// One downside is that the user currently viewing this topic/post is not taken into account.
if (empty($_REQUEST['f']))
{
$_REQUEST['f'] = $forum_id;
}
replace with:
- Code: Select all
// 301 Redirect PHPBB 2 posts to PHPBB 3
// please provide link to greensboring.com if used
// You may need to add the folder to the path follow http_host variable if installed in a subfolder.
if (empty($_REQUEST['f']) && empty($_REQUEST['p']))
{ header("Status: 301 Moved Permanently", true, 301);
header("Location: http://{$_SERVER['HTTP_HOST']}/viewtopic.php?f={$forum_id}&t={$topic_id}");
exit();
}
MOVED POSTS:
Has Topic Moved to a New Forum?
- Code: Select all
// this prevents two urls if topic is moved to different forum
// You may need to add the folder to the path follow http_host variable if installed in a subfolder.
if ($_REQUEST['f'] != $forum_id)
{ header("Status: 301 Moved Permanently", true, 301);
header("Location: http://{$_SERVER['HTTP_HOST']}/viewtopic.php?f={$forum_id}&t={$topic_id}");
exit();
}
FIX FOR PHPBB'S SCREWY URL ARCHITECTURE:
LAST POST PAGINATION MOD:
FIND IN VIEWFORUM.PHP:
- Code: Select all
// Send vars to template
$template->assign_block_vars('topicrow', array(
BEFORE IT ADD:
- Code: Select all
//begin mod
$beancount=0;
$tp=0;
$sql = 'SELECT COUNT(post_id) AS num_posts
FROM ' . POSTS_TABLE . "
WHERE topic_id = $topic_id";
$result2 = $db->sql_query($sql);
$total_posts2 = (int) $db->sql_fetchfield('num_posts');
$db->sql_freeresult($result2);
if (($total_posts2) > ($config['posts_per_page'])) {
$tp=($total_posts2 / $config['posts_per_page']);
$beancount=(floor($tp) * $config['posts_per_page']);
}
if ($beancount >= 25) {
$libre='&start='.$beancount;
}
else {
$libre='';
}
//endofmod
FIND:
- Code: Select all
'U_LAST_POST' => $view_topic_url . '&p=' . $row['topic_last_post_id'] . '#p' . $row['topic_last_post_id'],
REPLACE WITH:
- Code: Select all
'U_LAST_POST' => $view_topic_url . $libre . '#p' . $row['topic_last_post_id'],
OPEN VIEWTOPIC & FIND: (These does remove sorting, but cleans up urls)
- Code: Select all
// If we've got a hightlight set pass it on to pagination.
$pagination = generate_pagination(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&$u_sort_param" . (($highlight_match) ? "&hilit=$highlight" : '')), $total_posts, $config['posts_per_page'], $start);
REPLACE WITH:
- Code: Select all
// If we've got a hightlight set pass it on to pagination.
$pagination = generate_pagination(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id"), $total_posts, $config['posts_per_page'], $start);
LINKS:
(add nofollow, and open in new window)
Install this short mod here: Open PHPBB links in new window (and nofollow)
More Canonicalization.... using rel=tag (This mod is setup for only those sites who are setup in the rootdirectory. You would need to modify this for subdomain installs, etc.... or just skip all together)
Makes sure PHP is turned on in your templates.... and add this in your overal_lheader.tpl above the <title> tag.
- Code: Select all
<!-- PHP -->
if (isset($_SERVER['PHP_SELF'])) {
if ($_SERVER['PHP_SELF']=='/index.php') {
echo '<link rel="canonical" href="http://'.$_SERVER['HTTP_HOST'].'"/>';
}
if ($_SERVER['PHP_SELF']=='/viewforum.php') {
if (isset($_GET['start']) && $_GET['start']!=0) {$page="&start=".$_GET['start'];}
echo '<link rel="canonical" href="http://'.$_SERVER['HTTP_HOST'].'/viewforum.php?f='.$_GET['f'].$page.'"/>';
}
if ($_SERVER['PHP_SELF']=='/viewtopic.php') {
if (isset($_GET['start']) && $_GET['start']!=0) {$page="&start=".$_GET['start'];}
echo '<link rel="canonical" href="http://'.$_SERVER['HTTP_HOST'].'/viewtopic.php?f='.$_GET['f'].'&t='.$_GET['t'].$page.'"/>';
}
}
<!-- ENDPHP -->
SIGNATURES
Display once per page:
FIND:
//
$postrow = array(
'POST_AUTHOR_FULL' => get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
ADD BEFORE:
- Code: Select all
// Sig displayed only Once Per Topic
if (!$signature[$poster_id])
{ $signature[$poster_id] = 1; }
else
{ $user_cache[$poster_id]['sig'] = ""; }
// End Mod
Find Beer
- Code: Select all
Drink
EOM

