I am using HTMLPurifier for PHP to ensure that all external links in a piece of HTML that the user provides have the nofollow tag. The problem Is that when I run the code, it will make all links nofollow, including those for my own domain. How are you supposed to make just external links and not the internal links for your own website?
1 Answer
You will need to provide the code to give an idea of what is going wrong but more than likely the issue is related to the config you are using to get this setup. Check to make sure you are setting the URI.Host property to the domain. The library is not able to figure out your domain name by default as the script could run as a cron task or something else. Your server is just an IP address remember. The library won't have access to the DNS info and even if it did, you could have multiple domains pointing at the one server IP. By providing the library with the domain name, it will know that this is the host and will not add a nofollow attribute to any links for this domain.
$config = HTMLPurifier_Config::createDefault(); $config->set("URI.Host", "mydomain.com"); $config->set('HTML.Nofollow', true); $config->set('HTML.SafeIframe', true); $config->set('Attr.EnableID', true);
Related Questions
Convert Json To Xml
Bitrate Converter
JavaScript Multi-line String Builder
GUID Generator
GUID Validator
Convert Json To C# Class