Last updated on May 4th, 2018 at 01:43 am
I found out that Spammers has turned one my website into their hub. So, I came up with this code to discourage them from posting on my site and also remain on the good side of Google. The code will automatically attribute a rel=”nofollow” to all the external anchor tags on your website.
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js' type='text/javascript'></script>
<script type='text/javascript'>
$(document).ready(function(){ $("a[href^='http://']").each(
function(){
if(this.href.indexOf(location.hostname) == -1) {
$(this).attr('rel', 'nofollow');
}
});
$("a[href^='https://']").each( function(){
if(this.href.indexOf(location.hostname) == -1) {
$(this).attr('rel', 'nofollow');
}
});
});
</script>
Simply paste the code on the <head></head> section of your website.
Did you get the answer you were searching for?
Save hours of searching online or wasting money testing unnecessary plugins, get in touch with me and let's discuss a suitable plan for your project. Best thing about this service is that you are never placed on hold and get to talk to an expereinced Oxwall/Skadate developer.
Get Answers for Free!
Ask a question related to this topic and get immediate answers from other community members in 48hrs or less. Contribute by answering members questions.
Ask Question
Premium Service
Whether it's a custom plugin, theme or dedicated support needed to get you started on your project, get professional 24/7 support tailored to your need.
Get in Touch
Or just leave a comment...