2009-08-31, 06:26 PM
Hi guys, i wanna modify some links before sending page output. I'm using Google SEO Plugin, that works correctly. At the top of this plugin, I simply added the following code:
Inside the same file, I put my function code:
I wanna adding the nofollow attribute to some links that I don't want show to search engines, like Google.
But... the forum index page appears blank... looking to the http headers, I found a 301 error (moved permanently)... other pages (like forums and threads) works fine and all the links are nofollow!
If I remove my code, all works again! How can I fix this bug?
Thanks a lot and sorry for my english
$plugins->add_hook("pre_output_page", "seo_change_links");
Inside the same file, I put my function code:
function seo_change_links($page)
{
global $mybb;
$page = preg_replace("#(<a.+?href=.+?(search|stats|usercp2|printthread|sendthread|showteam|memberlist|calendar|member|online|private|newreply|newthread|showthread|forumdisplay)\.php)(.+?)>(.+?)</a>#e", "seo_add_nofollow('\\1', '\\3', '\\4')", $page);
return $page;
}
/**
* Adds rel="nofollow" in the data provided by matches
* in parts.
*
* @access private
*/
function seo_add_nofollow($part_1, $part_2, $part_3)
{
return stripslashes($part_1) . stripslashes($part_2) . ' rel="nofollow">'. stripslashes($part_3) .'</a>';
}
I wanna adding the nofollow attribute to some links that I don't want show to search engines, like Google.
But... the forum index page appears blank... looking to the http headers, I found a 301 error (moved permanently)... other pages (like forums and threads) works fine and all the links are nofollow!
If I remove my code, all works again! How can I fix this bug?
Thanks a lot and sorry for my english