Google and phpBB

8) This is cool to make your board better for google

 

#

[ OPEN ]

includes/sessions.php

#

[ FIND ]

global $SID;

if ( !empty($SID) && !preg_match('#sid=#', $url) )

#

[ REPLACE WITH ]

global $SID, $HTTP_SERVER_VARS;

if ( !empty($SID) && !preg_match('sid=', $url) && !strstr($HTTP_SERVER_VARS ,'Googlebot') && !strstr($HTTP_SERVER_VARS ,'slurp@inktomi.com'))

#
#

[ SAVE/CLOSE ALL FILES ]

#
# EoM

 

If that doesnt work try, but guest cant post, u go to disable tha, like i did in here lol

 

#
#

[ OPEN ]

#
includes/sessions.php

#
#

[ FIND ]

#
$SID = 'sid=' . $session_id;

#
#

[ REPLACE WITH ]

#
if ( $userdata != ANONYMOUS ){
$SID = 'sid=' . $session_id;
} else {
$SID = '';
}

Ok make the robots.txt pu it in the forum root

User-agent: *
Disallow: /admin/
Disallow: /attach_mod/
Disallow: /db/
Disallow: /files/
Disallow: /images/
Disallow: /includes/
Disallow: /language/
Disallow: /mycalendar_mod/
Disallow: /spelling/
Disallow: /templates/
Disallow: /common.php
Disallow: /config.php
Disallow: /glance_config.php
Disallow: /groupcp.php
Disallow: /memberlist.php
Disallow: /mini_cal.php
Disallow: /modcp.php
Disallow: /mycalendar.php
Disallow: /news_insert.php
Disallow: /posting.php
Disallow: /printview.php
Disallow: /privmsg.php
Disallow: /profile.php
Disallow: /ranks.php
Disallow: /search.php
Disallow: /statistics.php
Disallow: /tellafriend.php
Disallow: /viewonline.php

Below is the mod.. can be used with Mod #1 to get indexed in google faster..
It requires mod_rewrite enabled.. as directed below. (This mod is not in standard form but u can understand it.

Requirements: you need mod_rewrite enabled as well as ability to use .htaccess or modify apache config files.

Implementation:

Step 1. In /includes/page_header.php before

Code:
//
// Generate logged in/logged out status
//

add this code (make sure there are no space breaks at line ends after you paste):

Code:
ob_start();
function replace_for_mod_rewrite(&$s)
{
$urlin =
array(
"'(?<!/)viewforum.php?f=([0-9]*)&topicdays=([0-9]*)&start=([0-9]*)'",
"'(?<!/)viewforum.php?f=([0-9]*)&mark=topics'",
"'(?<!/)viewforum.php?f=([0-9]*)'",
"'(?<!/)viewtopic.php?t=([0-9]*)&view=previous'",
"'(?<!/)viewtopic.php?t=([0-9]*)&view=next'",
"'(?<!/)viewtopic.php?t=([0-9]*)&postdays=([0-9]*)&postorder=([a-zA-Z]*)&start=([0-9]*)'",
"'(?<!/)viewtopic.php?t=([0-9]*)&start=([0-9]*)&postdays=([0-9]*)&postorder=([a-zA-Z]*)&highlight=([a-zA-Z0-9]*)'",
"'(?<!/)viewtopic.php?t=([0-9]*)&start=([0-9]*)'",
"'(?<!/)viewtopic.php?t=([0-9]*)'",
"'(?<!/)viewtopic.php&p=([0-9]*)'",
"'(?<!/)viewtopic.php?p=([0-9]*)'",
);
$urlout = array(
"viewforum--.html",
"forum.html",
"forum.html",
"ptopic.html",
"ntopic.html",
"ftopic---.html",
"ftopic.html",
"ftopic-.html",
"ftopic.html",
"sutra.html",
"sutra.html",
);
$s = preg_replace($urlin, $urlout, $s);
return $s;
}

Step 2. In /includes/page_tail.php after

Code:
$db->sql_close();

add this:

Code:
$contents = ob_get_contents();
ob_end_clean();
echo replace_for_mod_rewrite($contents);
global $dbg_starttime;

in the same file after

Code:
ob_end_clean();

add this:

Code:
echo replace_for_mod_rewrite($contents);
global $dbg_starttime;

Step 3. In your .htaccess file (if you don't have one create it; should be located in you forum root directory) paste these lines:

Code:
RewriteEngine On
RewriteRule ^forums.* index.php
RewriteRule ^forum([0-9]*).* forum.html$1&mark=topic
RewriteRule ^viewforum([0-9]*)-([0-9]*)-([0-9]*).* forum.html$1&topicdays=$2&start=$3
RewriteRule ^forum([0-9]*).* forum.html$1
RewriteRule ^ptopic([0-9]*).* ftopic.html$1&view=previous
RewriteRule ^ntopic([0-9]*).* ftopic.html$1&view=next
RewriteRule ^ftopic([0-9]*)-([0-9]*)-([a-zA-Z]*)-([0-9]*).* ftopic.html$1&postdays=$2&postorder=$3&start=$4
RewriteRule ^ftopic([0-9]*)-([0-9]*).* ftopic.html$1&start=$2
RewriteRule ^ftopic([0-9]*).* ftopic.html$1
RewriteRule ^ftopic([0-9]*).html ftopic.html$1&start=$2&postdays=$3&postorder=$4&highlight=$5
RewriteRule ^sutra([0-9]*).* sutra.html$1

Note: sometimes this .htaccess code won't work properly if the forum is on a subdomain (was the case with me), you may need to try this variation:

Code:
RewriteEngine On
RewriteRule ^forums.* /index.php
RewriteRule ^forum([0-9]*).* /viewforum.php?f=$1&mark=topic
RewriteRule ^viewforum([0-9]*)-([0-9]*)-([0-9]*).* /viewforum.php?f=$1&topicdays=$2&start=$3
RewriteRule ^forum([0-9]*).* /viewforum.php?f=$1
RewriteRule ^ptopic([0-9]*).* /viewtopic.php?t=$1&view=previous
RewriteRule ^ntopic([0-9]*).* /viewtopic.php?t=$1&view=next
RewriteRule ^ftopic([0-9]*)-([0-9]*)-([a-zA-Z]*)-([0-9]*).* /viewtopic.php?t=$1&postdays=$2&postorder=$3&start=$4
RewriteRule ^ftopic([0-9]*)-([0-9]*).* /viewtopic.php?t=$1&start=$2
RewriteRule ^ftopic([0-9]*).* /viewtopic.php?t=$1
RewriteRule ^ftopic([0-9]*).html /viewtopic.php?t=$1&start=$2&postdays=$3&postorder=$4&highlight=$5
RewriteRule ^sutra([0-9]*).* /viewtopic.php?p=$1

Step 4. Very important! In your robots.txt file (goes at the *site* root) add these lines:

Code:
Disallow: /your-forum-folder/sutra*.html$
Disallow: /your-forum-folder/ptopic*.html$
Disallow: /your-forum-folder/ntopic*.html$
Disallow: /your-forum-folder/ftopic*asc*.html$

(This is required to avoid feeding duplicate content to Google)

Step 5. Apply Google Mod #1 described at this page.

Then there was a suggestion to make a sitemap page having static url to each topic in ur forum generated dynamically. This will allow google to get ur all topics indexed without Sids. But some suggest it is not a good idea for big forums because google don’t like more than 200 links on a page. Well the sitemap page u need is below..

<!--?php <br ?--> /***************************************************************************
* Save this file as: site_map.php (or anything you like)
* Version: Friday, Oct 4, 2002
* Email: angus@phphacks.com
* Purpose of hack: Basically generates a list of topics and
* displays them with link to the topic. Goal
* is to provide search engines like Google
* with a static page of links to dynamic pages
* You should link to this page from your sites
* home page somewhere.
* Demo: http://www.aussiecelebs.com/forums/site_map.php
* Tested on: phpBB 2.01, 2.02
*
***************************************************************************/

/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/

echo "

<!-- Start header here. Make sure you dont use any " s -->

&nbsp;
<h1>Site Map</h1>
<!-- End Header -->

";

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

echo "
<h2>All Categories</h2>
";

$result = mysql_query("SELECT cat_title, cat_id FROM phpbb_categories ORDER BY cat_title");
while($row= mysql_fetch_assoc($result))
{
echo "<a href="index.php?c=&quot;.$row[&quot;cat_id&quot;].&quot;">".$row["cat_title"]."</a>
";

}

echo "
<h2>All Forums</h2>
";

$result = mysql_query("SELECT forum_id, forum_name, forum_desc FROM phpbb_forums ORDER BY forum_name");
while($row= mysql_fetch_assoc($result))
{
echo "<a href="forum.html&quot;.$row[&quot;forum_id&quot;].&quot;">".$row["forum_name"]."</a>"." - ".$row["forum_desc"]."
";

}

echo "
<h2>All Topics</h2>
";

$result = mysql_query("SELECT topic_title, topic_id FROM phpbb_topics ORDER BY topic_title");
while($row= mysql_fetch_assoc($result))
{
echo "<a href="ftopic.html&quot;.$row[&quot;topic_id&quot;].&quot;">".$row["topic_title"]."</a>
";

}

echo "

<!-- Start footer here. -->

&nbsp;

<!-- End footer -->

";

?>

Place this page inside ur forum directory and give a link to ur site map in ur mainpage.

In addition to use that .. u can also use dynamic metatage generator by doing the following..

includes/page_header.php
find
Code:
define('HEADER_INC', TRUE);

after, add
Code:

// MOD TOPIC META TAGS BEGIN
// add meta tags - we only want to do this is specifaclly asked
if( isset($HTTP_GET_VARS) || isset($HTTP_POST_VARS) )
{
if ( isset($HTTP_GET_VARS[POST_TOPIC_URL]) )
{
$topic_id = intval($HTTP_GET_VARS[POST_TOPIC_URL]);
}
else if ( isset($HTTP_GET_VARS) )
{
$topic_id = intval($HTTP_GET_VARS);
}

if ( $topic_id )
{
$sql = "SELECT c.cat_title, f.forum_name, t.topic_title
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f, " . CATEGORIES_TABLE . " c
WHERE f.forum_id = t.forum_id
AND c.cat_id = f.cat_id
AND t.topic_id = $topic_id";
if( ($result = $db->sql_query($sql)) )
{
if ( $meta_row = $db->sql_fetchrow($result) )
{
$meta_description = '';
}
}
$sql = "SELECT w.word_text
FROM " . TOPICS_TABLE . " t, " . SEARCH_MATCH_TABLE . " m, " . SEARCH_WORD_TABLE . " w
WHERE t.topic_first_post_id = m.post_id
AND m.word_id = w.word_id
AND t.topic_id = $topic_id";
if( ($result = $db->sql_query($sql)) )
{
$meta_keywords = '';
while ( $meta_row = $db->sql_fetchrow($result) )
{
$meta_keywords .= ($meta_keywords=='') ? $meta_row : ',' . $meta_row;
}
$meta_keywords = '';
}
}
}
// MOD TOPIC META TAGS END

find
Code:
'PAGE_TITLE' => $page_title,

after, add
Code:

'META_DESCRIPTION' => $meta_description,
'META_KEYWORDS' => $meta_keywords,

in templates/subSilver/overall_header.tpl
find
Code:

after, add
Code:

{META_DESCRIPTION}
{META_KEYWORDS}

then all you need to do in your sitemap page is add...
Code:
&with_meta=

Also there are few more mods and they are good. but the above i have mention turns out to be the successfull and checked by various users feedback.

I found that there are basically 4 techniques developed in this thread. 3 as mod and one as creating a site map. so it will be nice the topic is splitted into 4 for or less parts starting freshly. I found this request various time in between the thread. Also these thread is so confusing as it is big. I decieded to read at once due to its large size.

Also I am very-very thankful to those who had worked a lot to provide varoious mods in this thread.

Also this thread provided some good link to various SEO related tools..
I only remember one posted by me earlier.. http://www.free-seo-tools.com

And at the end i apologize for my bad english .. also forgive me if i have done any mistake in giving the my view wht I got after reading the whole thread. If some thing is missing then please mention that .. i ll try to implement.

Leave a Reply

You must Register or Login to comment on Google and phpBB