Welcome! » Log In » Create A New Profile

Enforce rel="nofollow" to all Links

Posted by Florian 
Florian
Enforce rel="nofollow" to all Links
June 09, 2018 04:23AM

Installed HTMLpurifier today and it works nicely :)

Now i want to add rel="nofollow" to ALL Links, but i cant get it to work. Here is my config:

$config->set('HTML.Allowed', 'span,p,br,a,h1,h2,h3,h4,h5,strong'); $config->set('HTML.AllowedElements', array('span','p','br','a','h1','h2')); $config->set('HTML.AllowedAttributes', 'rel,style,title,href,border,alt,width,height,title'); $config->set('CSS.AllowedProperties', 'text-align,font-weight,text-decoration,background-color'); $config->set('HTML.AllowedRel', 'nofollow'); $config->set('HTML.Nofollow', true);

could you please help me, how do i enforce nofollow to all Links?

Cheers, florian

Florian
Re: Enforce rel="nofollow" to all Links
June 09, 2018 04:45AM

PS: Im using the standalone version.

Florian
Re: Enforce rel="nofollow" to all Links
June 10, 2018 04:36AM

Please give me a hint, i tried whole day yesterday. Or if this is not possible, please let me know.

Florian
Re: Enforce rel="nofollow" to all Links
June 10, 2018 04:46AM

Here is a simplified config, that i use, but still there is no rel=nofollow added:

require_once ($_SERVER["DOCUMENT_ROOT"].'/thirdparty/htmlpurifier/HTMLPurifier.standalone.php'); $config = HTMLPurifier_Config::createDefault();

$config->set('HTML.AllowedAttributes', 'rel,style'); $config->set('HTML.Nofollow', true);

$purifier = new HTMLPurifier($config);

return $purifier->purify( 'dwfef' );

Florian
Re: Enforce rel="nofollow" to all Links
June 10, 2018 04:55AM

Just managed to add rel=nofollow to links.

But it seems that it is only possible, if the url contains a leading "http" or "https".

this seems problematic, because a user might not always add these and just write "www.domain.com" instead of "http://www.domain.com".

Even if there was a way to also add this "http" prefix programmmatically, you dont know which protocol the url is using, http, or https.

Is there any solution, to add rel=nofollow to links without http(s) prefix?

Florian
Re: Enforce rel="nofollow" to all Links
June 11, 2018 11:32AM

Seems that i had some misconception regarding external links. now i see that there needs some protocol or // before url to be regarded as external link. My Fault. Thread solved.

Sorry, you do not have permission to post/reply in this forum.