MyBB Community Forums

Full Version: need to tag all external URLs with "nofollow" while internal links are followed
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have been looking for an updated solution for this issue for 1.6.12, but all solutions are outdated.

All I would like to do is to tag all external links in the postbit and signature with "nofollow" while all internal links in the postbit and signature remain regular links (followed).

I used to use this MyCode tutorial, but it no longer works with 1.6.12

http://community.mybb.com/thread-109466.html

I have been searching for other solutions and plugins but they're all outdated and the only couple solutions put nofollow on all links (external and internal) and only on new links (so the links from past posts are not tagged).

Can anybody help please? This is something that should have a solution as I'm sure there's many admins who need this.

Thanks
I found that the combination of the plug-ins Nofollow external, and Nofollow provide pretty good coverage, though I did have to make the change I mentioned here in order to get full coverage from Nofollow external.

I admit I was surprised that this a wasn't built-in/default feature, but those plug-ins seem to do fairly well. I think if someone posts a link to your domain it will still be nofollowed, which is a small annoyance that some clever person could fix, but all of the forum's own links will not be nofollowed, so your forum will be indexed.

I think there is an opportunity here for someone to make a unified/up to date nofolow plugin.
(2014-01-20, 05:37 PM)Dave H Wrote: [ -> ]I found that the combination of the plug-ins Nofollow external, and Nofollow provide pretty good coverage, though I did have to make the change I mentioned here in order to get full coverage from Nofollow external.

I admit I was surprised that this a wasn't built-in/default feature, but those plug-ins seem to do fairly well. I think if someone posts a link to your domain it will still be nofollowed, which is a small annoyance that some clever person could fix, but all of the forum's own links will not be nofollowed, so your forum will be indexed.

I think there is an opportunity here for someone to make a unified/up to date nofolow plugin.

The plugin in that thead where the bug was reported was working good until I noticed it was actually deleting the external links in members' signatures in the postbit.

I agree; I was surprised this didn't come as a default setting seeing that we have the possibility to make signature links nofollow. Having the option to make external (not internal!) links nofollow in the postbit would be a great setting that many of us would find useful instead of having to install outdated plugins and edit php (and many times screw things up).

Ok, I fixed it: now all my postbit external links are nofollowed and internal links are followed. I tried many (I think all) the solutions I could find through searching, but none worked, mostly because the plugins are outdated.

As I like to help others whenever possible, here is what I did in case someone finds himself in this situation.

1) Go to class_parser and find

$link = "<a href=\"$fullurl\" target=\"_blank\"{$nofollow}>$name</a>";

2) Change the code to this:

$link = "<a rel=\"nofollow\" href=\"$fullurl\" target=\"_blank\">$name</a>";

3) Now create a plugin with the following code (below) and name it nofollowlink.php


<?php
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

$plugins->add_hook("parse_message_end", "nofollowlink_changelink");

function nofollowlink_info()
{

return array(
"name" => "Removes Nofollow from Internal links",
"description" => "A simple plugin that removes nofollow from your internal links",
"website" => "http://letsforum.com",
"author" => "Victor Dub",
"authorsite" => "http://letsforum.com",
"version" => "1.0",
"guid" => "0fead3ffd1a376ceb5cef3388df5d39d",
"compatibility" => "*"
);
}

function nofollowlink_changelink($message){
global $mybb;
$my_site = $mybb->settings['bburl'];
$search = '<a rel="nofollow" href="'.$my_site.'';
$replace = '<a href="'.$my_site.'';
$message = str_replace($search , $replace , $message);
return $message;
}
?>


Done! I spent some time researching the different venues and the plugin code is from this website (if possible, leave the credit text when putting in the code for the plugin as a thank you to this guy):

http://letsforum.com/Thread-MyBB-Add-NOF...User-Links

Make sure that you aren't using any plugin currently to nofollow links including any plugin using customized MyCode. Also, make sure that yo have turned off the nofollow option in the Google SEO plugin if using it.

Enjoy!
(2014-01-20, 05:58 PM)Ados Wrote: [ -> ]Ok, I fixed it: now all my postbit external links are nofollowed and internal links are followed. I tried many (I think all) the solutions I could find through searching, but none worked, mostly because the plugins are outdated.

As I like to help others whenever possible, here is what I did in case someone finds himself in this situation.

1) Go to class_parser and find

$link = "<a href=\"$fullurl\" target=\"_blank\"{$nofollow}>$name</a>";

2) Change the code to this:

$link = "<a rel=\"nofollow\" href=\"$fullurl\" target=\"_blank\">$name</a>";

3) Now create a plugin with the following code (below) and name it nofollowlink.php


<?php
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

$plugins->add_hook("parse_message_end", "nofollowlink_changelink");

function nofollowlink_info()
{

return array(
"name" => "Removes Nofollow from Internal links",
"description" => "A simple plugin that removes nofollow from your internal links",
"website" => "http://letsforum.com",
"author" => "Victor Dub",
"authorsite" => "http://letsforum.com",
"version" => "1.0",
"guid" => "0fead3ffd1a376ceb5cef3388df5d39d",
"compatibility" => "*"
);
}

function nofollowlink_changelink($message){
global $mybb;
$my_site = $mybb->settings['bburl'];
$search = '<a rel="nofollow" href="'.$my_site.'';
$replace = '<a href="'.$my_site.'';
$message = str_replace($search , $replace , $message);
return $message;
}
?>


Done! I spent some time researching the different venues and the plugin code is from this website (if possible, leave the credit text when putting in the code for the plugin as a thank you to this guy):

http://letsforum.com/Thread-MyBB-Add-NOF...User-Links

Make sure that you aren't using any plugin currently to nofollow links including any plugin using customized MyCode. Also, make sure that yo have turned off the nofollow option in the Google SEO plugin if using it.

Enjoy!

I'm bumping to say thanks and it's the only nofollow method I've tried that works.
This is something that every forum needs to do in order to avoid unnatural links being registered!
What is the default behavior of myBB?

All links are followable?

Does this fix cover all links in posts? Or only signatures?
Hello friend!

With this, all links outside the MyBB folder / url, receive nofollow. Links to other urls from the same domain also receive nofollow. But I want the nofollow is only for links outside the domain, not out of MyBB installation folder / url.

How do I only links outside the main domain receive the nofollow?

Example of how it is today:
  • mysite.com/mybb/forumdisplay.php?fid=13 (don´t receive nofollow)
  • mysite.com/wordpress/page.html (receive nofollow)
  • mysite.com/ (receive nofollow)
  • google.com/ (receive nofollow)
Example of I want it to be:
  • mysite.com/mybb/forumdisplay.php?fid=13 (don´t receive nofollow)
  • mysite.com/wordpress/page.html (don´t receive nofollow)
  • mysite.com/ (don´t receive nofollow)
  • google.com/ (receive nofollow)
Thank you.
For whoever this might be helpful to, I modified the plugin file to remove the "nofollow" from more than just your own forums, if you have other domains you want to allow, for example.
<?php
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

$plugins->add_hook("parse_message_end", "nofollowlink_changelink");

function nofollowlink_info()
{

return array(
"name" => "Removes Nofollow from Internal links",
"description" => "A simple plugin that removes nofollow from your internal links",
"website" => "http://letsforum.com",
"author" => "Victor Dub",
"authorsite" => "http://letsforum.com",
"version" => "1.0",
"guid" => "0fead3ffd1a376ceb5cef3388df5d39d",
"compatibility" => "*"
);
}

function nofollowlink_changelink($message){
// site home
$my_site = "http://YOURDOMAIN.com";
$search = '<a rel="nofollow" href="'.$my_site.'';
$replace = '<a href="'.$my_site.'';
$message = str_replace($search , $replace , $message);
// site news
$my_site = "http://news.YOURDOMAIN.com";
$search = '<a rel="nofollow" href="'.$my_site.'';
$replace = '<a href="'.$my_site.'';
$message = str_replace($search , $replace , $message);
// site forums
$my_site = "http://forums.YOURDOMAIN.com";
$search = '<a rel="nofollow" href="'.$my_site.'';
$replace = '<a href="'.$my_site.'';
$message = str_replace($search , $replace , $message);
return $message;
}
?>
You could obviously replace the $my_site string with just about any domain you consider "safe", to allow following. Seems pretty obvious, but might help someone less knowledgeable out there. Smile

There's probably a more elegant solution out there, but this works for my needs.