Travel
 | 
Food
 | 
Arts
 | 
Advice
 | 
Life
 | 
Greensboro
 |  Secularity |  Blog

SEO for PHPBB 3 - A Checklist Mod for fresh installs

by Liv | Published on April 24th, 2007, 7:16 pm | Advice
Updated: March 29, 2011 for 3.0.8

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 - 3/29/2011


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 includes/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 in includes/functions.php
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'], true, $forum_id);

#
#-----[ 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'] >= $config['posts_per_page']){ page_header($topic_data['topic_title']." | ".$topic_data['forum_name']);}
else { page_header($topic_data['topic_title']);}



#
#-----[ OPEN ]------------------------------------------
#

styles/subSilver/template/overall_header.html

#
#-----[ FIND ]------------------------------------------
#

<title>{SITENAME} &bull; {PAGE_TITLE}</title>

#
#-----[ REPLACE WITH ]------------------------------------------
#

<title><!-- IF S_IN_MCP -->{L_MCP} &bull; <!-- ELSEIF S_IN_UCP -->{L_UCP} &bull; <!-- ENDIF -->{PAGE_TITLE}</title>

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM



HANDLING DELETED POSTS & BAD FORUM REQUESTS:
Please note that the procedure since 3.0.5 has been updated and simplified. Previous methods are no longer valid. This handles incorrect, and moved posts as well as deleted topics by redirecting them via Apache 301 to either the correct place or the homepage.

Open viewtopic.php & Find:

Code: Select all
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);


Below it add:

Code: Select all
$topic_id   = request_var('t', 0);
$sql = 'SELECT forum_id
         FROM ' . TOPICS_TABLE . "
         WHERE topic_id = $topic_id";
      $result = $db->sql_query($sql);
      $forum_id = (int) $db->sql_fetchfield('forum_id');
      $db->sql_freeresult($result);

      if (!$forum_id)
      {
      header("Status: 301 Moved Permanently", true, 301);
            header("Location: $phpbb_root_path");
            exit();
      }
      if ($_REQUEST['f'] != $forum_id)
          {
      header("Status: 301 Moved Permanently", true, 301);
          header("Location: {$phpbb_root_path}viewtopic.php?f={$forum_id}&t={$topic_id}");
            exit();
            }




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=*


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
// URL START MOD
if ($row['topic_replies'] > $config['posts_per_page'])
    {
    $start=floor($row['topic_replies'] / $config['posts_per_page']);
    $start=$start*$config['posts_per_page'];
    $start='&amp;start='.$start;
    }
else
    {
    $start='';
    }
// END URL START MOD


FIND:

Code: Select all
        'U_LAST_POST'            => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&amp;p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'],


REPLACE WITH:
Code: Select all
    'U_LAST_POST'            => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . $start) . '#p' . $row['topic_last_post_id'],



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 overall_header.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.'"/>';
echo '<meta name="robots" content="noindex, follow">';
}

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.'"/>';
echo '<link name="original-source" content="http://'.$_SERVER['HTTP_HOST'].'/viewtopic.php?f='.$_GET['f'].'&t='.$_GET['t'].$page.'"/>';
}

}

<!-- ENDPHP -->

SIGNATURES
Display once per page:

FIND in viewtopic.php:
Code: Select all
       //
       $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


Turning off word censor for registered users:
FIND:
Code: Select all
$message = censor_text($row['post_text']);


REPLACE WITH:
Code: Select all
if (!$user->data['is_bot'] && $user->data['is_registered']) {
   $message = $row['post_text'];
} else
{
   $message = censor_text($row['post_text']);
}


Find Beer

Code: Select all
Drink


EOM

 
Thank you for this tutorial. Greatly appreciated.

Regards,
snow
snow
 
thanks, that helped me a lot!
regards,
chantal
Zippie28
 
cron