Zach Bloomquist

Adding rel=nofollow to outgoing links in MyBB

If you run a forum, you probably have spammers signing up all the time, posting links on your site and stealing your valuable PageRank. MyBB offers a way to add rel=”nofollow” to outgoing links in posts via a creative use of the MyCode functionality.

To add rel=”nofollow” to outgoing links, first go to your admin panel in MyBB. Visit the Configuration tab, and then select MyCode on the left sidebar. We’ll be adding two new MyCode. Click “Add New MyCode” and fill it out like so:

  • Title: Nofollow
  • Regular Expression: href=”http([s]?)://(.*?)”
  • Replacement: href=”http$1://$2” rel=”nofollow”
  • Enabled: Yes
  • Parse order: 99

This MyCode will go through every link in a post and add rel=”nofollow” to them all. It will even add rel=”nofollow” to links which point to your own website, which is probably not what you want! To avoid this, add another MyCode which will strip rel=”nofollow” from local links:

  • Title: Dofollow
  • Regular Expression: href=”http([s]?)://( www.)*?)” rel=”nofollow”
  • Replacement: href=”http$1://$$3”
  • Enabled: Yes
  • Parse order: 100
Replace with your actual domain name. This MyCode will strip rel=”nofollow” from and links. If you want to add multiple domains, you do not have to create multiple MyCodes! Just replace “” in the Regular Expression with “(” and replace “$3” in the Replacement with “$3$4”.

There you go! Just a few quick steps to protecting your PageRank against spammers, without any nasty code modifications or plugins. :)

Comments on "Adding rel=nofollow to outgoing links in MyBB"