MyBB Community Forums

Full Version: Adding nofollow to outgoing links
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
Hi!

Adding the nofollow relation to links (rel="nofollow") is quite simple by using the very powerful MyCode editor within MyBB.

With the MyCode editor you can do more things than adding own MyCodes. Its a powerful Regex editor for posts. Exclamation

So, to add rel="nofollow" to all links you just need to add the following MyCode:

Title
Nofollow

Regular Expression
<a href="http([s]?)://(.*?)"

Replacement
<a href="http$1://$2" rel="nofollow"

That's it! But wait: Now all links are nofollow, also links to your own site. So we need another MyCode to remove the nofollow relation from all internal links:

Title
Dofollow

Regular Expression
<a href="http([s]?)://(|www\.)example.net(.*?)" rel="nofollow"

Replacement
<a href="http$1://$2example.net$3"

Replace example.net with your own URL! If you have more sub domains than www just add them to the regular expression:

<a href="http([s]?)://(|www\.|sub1\.|sub2\.)example.net(.*?)" rel="nofollow"

Hint: This only works with stock MyBB URLs. If you use plugins which modify URLs you may have to change the regular expression!

PS: Of course it's possible to combine both regular expressions. If you are a pro please post the regular expression here! Smile
Very nice! Smile

But just wondering, is this considered a good practice SEO-wise?
(2010-11-01, 05:05 PM)faviouz Wrote: [ -> ]But just wondering, is this considered a good practice SEO-wise?

You pays your money and you takes your choice. Wink

This tutorial just demonstrates how to alter user posts.
(2010-10-28, 01:03 PM)querschlaeger Wrote: [ -> ]Hi!

Adding the nofollow relation to links (rel="nofollow") is quite simple by using the very powerful MyCode editor within MyBB.

With the MyCode editor you can do more things than adding own MyCodes. Its a powerful Regex editor for posts. Exclamation

So, to add rel="nofollow" to all links you just need to add the following MyCode:

Title
Nofollow

Regular Expression
<a href="http([s]?)://(.*?)"

Replacement
<a href="http$1://$2" rel="nofollow"

That's it! But wait: Now all links are nofollow, also links to your own site. So we need another MyCode to remove the nofollow relation from all internal links:

Title
Dofollow

Regular Expression
<a href="http([s]?)://(|www.\)example.net(.*?)" rel="nofollow"

Replacement
<a href="http$1://$2example.net$3"

Replace example.net with your own URL! If you have more sub domains than www just add them to the regular expression:

<a href="http([s]?)://(|www.\|sub1\.|sub2\.)example.net(.*?)" rel="nofollow"

Hint: This only works with stock MyBB URLs. If you use plugins which modify URLs you may have to change the regular expression!

PS: Of course it's possible to combine both regular expressions. If you are a pro please post the regular expression here! Smile

I did as what you said. In the both, No follow working well. But When I enable Do follow Code th following errors showing given below. I am using mybb 1.6. Please resovle this problem. Thanks in advance.
The following warnings occurred:
Warning [2] preg_replace() [function.preg-replace]: Compilation failed: missing ) at offset 65 - Line: 342 - File: inc/class_parser.php PHP 5.2.14 (Linux)
File 	Line 	Function
[PHP] 	  	errorHandler->error
/inc/class_parser.php 	342 	preg_replace
/inc/class_parser.php 	152 	postParser->parse_mycode
/inc/functions_post.php 	577 	postParser->parse_message
/showthread.php 	928 	build_postbit
Warning [2] preg_replace() [function.preg-replace]: Compilation failed: missing ) at offset 65 - Line: 342 - File: inc/class_parser.php PHP 5.2.14 (Linux)
File 	Line 	Function
[PHP] 	  	errorHandler->error
/inc/class_parser.php 	342 	preg_replace
/inc/class_parser.php 	152 	postParser->parse_mycode
/inc/functions_post.php 	591 	postParser->parse_message
/showthread.php 	928 	build_postbit
Warning [2] preg_replace() [function.preg-replace]: Compilation failed: missing ) at offset 65 - Line: 342 - File: inc/class_parser.php PHP 5.2.14 (Linux)
File 	Line 	Function
[PHP] 	  	errorHandler->error
/inc/class_parser.php 	342 	preg_replace
/inc/class_parser.php 	152 	postParser->parse_mycode
/inc/functions_post.php 	577 	postParser->parse_message
/showthread.php 	928 	build_postbit
Warning [2] preg_replace() [function.preg-replace]: Compilation failed: missing ) at offset 65 - Line: 342 - File: inc/class_parser.php PHP 5.2.14 (Linux)
File 	Line 	Function
[PHP] 	  	errorHandler->error
/inc/class_parser.php 	342 	preg_replace
/inc/class_parser.php 	152 	postParser->parse_mycode
/inc/functions_post.php 	591 	postParser->parse_message
/showthread.php 	928 	build_postbit
Warning [2] preg_replace() [function.preg-replace]: Compilation failed: missing ) at offset 65 - Line: 342 - File: inc/class_parser.php PHP 5.2.14 (Linux)
File 	Line 	Function
[PHP] 	  	errorHandler->error
/inc/class_parser.php 	342 	preg_replace
/inc/class_parser.php 	152 	postParser->parse_mycode
/inc/functions_post.php 	577 	postParser->parse_message
/showthread.php 	928 	build_postbit
Warning [2] preg_replace() [function.preg-replace]: Compilation failed: missing ) at offset 65 - Line: 342 - File: inc/class_parser.php PHP 5.2.14 (Linux)
File 	Line 	Function
[PHP] 	  	errorHandler->error
/inc/class_parser.php 	342 	preg_replace
/inc/class_parser.php 	152 	postParser->parse_mycode
/inc/functions_post.php 	591 	postParser->parse_message
/showthread.php 	928 	build_postbit
Warning [2] preg_replace() [function.preg-replace]: Compilation failed: missing ) at offset 65 - Line: 342 - File: inc/class_parser.php PHP 5.2.14 (Linux)
File 	Line 	Function
[PHP] 	  	errorHandler->error
/inc/class_parser.php 	342 	preg_replace
/inc/class_parser.php 	152 	postParser->parse_mycode
/inc/functions_post.php 	577 	postParser->parse_message
/showthread.php 	928 	build_postbit
Warning [2] preg_replace() [function.preg-replace]: Compilation failed: missing ) at offset 65 - Line: 342 - File: inc/class_parser.php PHP 5.2.14 (Linux)
File 	Line 	Function
[PHP] 	  	errorHandler->error
/inc/class_parser.php 	342 	preg_replace
/inc/class_parser.php 	152 	postParser->parse_mycode
/inc/functions_post.php 	591 	postParser->parse_message
/showthread.php 	928 	build_postbit
(2010-11-11, 12:37 PM)mahigrafix Wrote: [ -> ]I did as what you said. In the both, No follow working well. But When I enable Do follow Code th following errors showing given below. I am using mybb 1.6. Please resovle this problem. Thanks in advance.

Please post your Regular Expression here. It seems you have a typo in it.
(2010-11-11, 12:59 PM)querschlaeger Wrote: [ -> ]
(2010-11-11, 12:37 PM)mahigrafix Wrote: [ -> ]I did as what you said. In the both, No follow working well. But When I enable Do follow Code th following errors showing given below. I am using mybb 1.6. Please resovle this problem. Thanks in advance.

Please post your Regular Expression here. It seems you have a typo in it.

My website is http://www.mahigrafix.com . (I added no follow to post bit buttons manually before do this.)

I used the reqular expression given below:

<a href="http([s]?)://(|www.\)mahigrafix.com(.*?)" rel="nofollow"

Replacement Expression

<a href="http$1://$2mahigrafix.com$3"
Hi querschlaeger,

I tried the below code: Toungue . But the same error. I don't have awareness on mybb expressions. Just tried. Is there any another way to replace expression for post body links only? Thanks in advance.

Regular Expression

<div id="" class="post_body">

<a href="http([s]?)://(|www.\)mahigrafix.com(.*?)" rel="nofollow"

</div>

Replacement

<div id="" class="post_body">

<a href="http$1://$2mahigrafix.com$3"

</div>
Ah, after a longer view I found it!

(2010-11-11, 01:03 PM)mahigrafix Wrote: [ -> ]
<a href="http([s]?)://(|www.\)mahigrafix.com(.*?)" rel="nofollow"

You have a typo:

(|www.\) - dot and backslash are interchanged. Wink
(2010-11-13, 05:58 PM)querschlaeger Wrote: [ -> ]Ah, after a longer view I found it!
You have a typo:

(|www.\) - dot and backslash are interchanged. Wink

Wow!! Amazing.. You are great. It worked. Thanks a lot. Smile .
(2010-11-01, 05:05 PM)faviouz Wrote: [ -> ]But just wondering, is this considered a good practice SEO-wise?
You can read about google and "nofollow" at google help http://www.google.com/support/webmasters...swer=96569

Pages: 1 2 3 4