Add canonical links to phpBB

phpbb-logo-greenIt’s old news that Google and other major search engines have added support for the <link rel="canonical"> tag to help cut down on duplicate indexing of web pages. While plugins for Wordpress, Drupal and Magneto E-Commerce have been released, there has been none such modification for phpBB, where it is, arguably, most needed.

phpBB administrators have used various methods to cut down on this duplicate indexing issue, but adding a canonical URL seems to be the most subtly effective way. Google honours this tag very strongly, and upon finding it in a web page, it should only index the canonical page.

In the view of all this, I have put together a mod for phpBB3 to add the canonical links to phpBB board pages. The Canonical URL mod adds these lines to the phpBB pages :

In the index page :

<link rel="canonical" href="http://www.example.com/" />

In the forum pages :

<link rel="canonical" href="http://www.example.com/viewforum.php?f=1" />

In the topic pages :

<link rel="canonical" href="http://www.example.com/viewforum.php?f=1&t=1" />

For global threads* :

<link rel="canonical" href="http://www.example.com/viewforum.php?t=1" />

phpBB.com support thread :

http://www.phpbb.com/community/viewtopic.php?f=69&t=1880545

Download modification :

download

Note :

Normally, global threads will have canonical URLs like this :

<link rel="canonical" href="http://www.example.com/viewforum.php?t=1" />

If you want the global threads to have canonical URLs with an “f=Y” query string, you just need to make a little change to the code. After installing the mod, open viewtopic.php.
Find :

   'U_CANONICAL'    => generate_board_url() . "/viewtopic.$phpEx?" . (($topic_data['topic_type'] == POST_GLOBAL) ? '' : "f=$forum_id&amp;") . "t=$topic_id" . (($start) ? "&amp;start=$start" : ''),

In-line Find :

? ''

Replace with :

? "f=Y&amp;"

Replace ‘Y’ with the forum id of the forum you want your global threads to belong to.

Related posts:

  1. phpBB: Redirect broken links after uninstalling an SEO mod
  2. Prevent duplicate indexing while moving threads in phpBB
  3. Prevent duplicate indexing of phpBB3 threads by Google
  4. Error: [phpBB Debug] PHP Notice: in file /includes/functions.php on line 3526: Undefined index: HIDDEN_USERS_ZERO_TOTAL_AND

2 Comments

  1. Karate_BKC says:

    Dear sir,
    I would like to try to download your conical url module. expected, this module can work fine at our site forum.
    Thanks sir,
    Karate BKC Indonesia

  2. Soumik says:

    Your forum apparently runs on SMF. :)

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>