News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Adding nofollow to all external links

Started by Biology Forums, April 16, 2014, 01:06:57 AM

Previous topic - Next topic

Biology Forums

In Subs.php, I'm trying to add rel="nofollow" to all links that don't possess my URL ($boardurl).

For example, if I linked cnn.com, the html would be <a rel="nofollow" href="cnn.com", whereas if I linked my own site MYURL.com, the html wouldn't contain rel="nofollow".

Can someone tell me how to accomplish this? This is what I've achieved so far, but it's causing all links to contain rel="nofollow"

global $boardurl;
if(strpos($message, '<a href') !== false)
$message = preg_replace('~(<a)( href="(?!' . preg_quote($boardurl) . ')(?:[^"]*?)"(?:[^>]*?)\>(?:.*?)</a>)~i', '$1 rel="nofollow"$2 ', $message);


This is going near the end of function parse_bbc. This is for 1.1.19.

Any suggestions?

margarett

Actually I'm pretty sure that a mod for this did exist. If only I could find it...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Deaks

~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."


margarett

I checked now, there was really an unapproved mod. :(
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Biology Forums

Quote from: margarett on April 21, 2014, 05:35:23 AM
I checked now, there was really an unapproved mod. :(

Can you provide the link?

Deaks

~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

Illori

i think he was talking about http://www.simplemachines.org/community/index.php?topic=510778.0 which became a mod and the author and mod are now gone.

margarett

Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair


Advertisement: