title: How to no-follow all external links automatically - jQuery
body: <p>I want to add <code>rel="nofollow"</code> attribute in all my external links. Below code works well on links comes with <code>http://</code> and <code>https://</code>. my problem is its not worked on links without <code>http</code> (ex: <code>/somepage.html</code>) how can i over come this.</p>
  
  <p>Any solution highly appreciated.</p>
  
  <p><strong><a href="http://jsfiddle.net/esv85nx1/" rel="nofollow">JS Fiddle</a></strong></p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;a href="http://www.somepage.com"&gt;This is an internal link&lt;/a&gt;
  &lt;br /&gt;&lt;br /&gt;
  &lt;a href="http://google.com"&gt;And this is an external link, with no follow (working)&lt;/a&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;a href="google.com"&gt;And this is an external link, with no follow (not-working)&lt;/a&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;a href="https://plus.google.com/101147114025225446015/about"&gt;And this is an external link, with no follow (working)&lt;/a&gt;
  </code></pre>
  
  <p><strong>JS</strong></p>
  
  <pre><code>jQuery('a[href*="http://"]:not([href*="http://www.somepage.com"])').attr('rel', 'nofollow');
  
  jQuery('a[href*="https://"]:not([href*="http://www.somepage.com"])').attr('rel', 'nofollow');
  
  jQuery('a[href*="https://"]:not([href*="https://www.somepage.com"])').attr("target", "_blank");
  </code></pre>
  
  <p><strong><a href="http://jsfiddle.net/esv85nx1/" rel="nofollow">JS Fiddle</a></strong></p>