I tried in this way but it is not working:
Java Script:
<script type="text/javascript">
function DoNav(theUrl)
{
document.location.href = theUrl;
}
</script>
Php code:
echo " onclick=\"DoNav('https://www.example.com/profile.php?id={$profile_id}'rel='nofollow');\">\n";
nofollow concerns a classic link, not for a link opened on JS. It's for search engine robots.
// Will indicate a robot that it does not have to follow this link
<a href="http://www.link.com" rel="nofollow"></a>
// If your action is JS opened you don't care to set nofollow, robots won't go on it.
<a href="#" onclick="window.open('http://www.link.com');"></a>
If you just want to prevent robot from accessing a particular adress on your website, you should use robots.txt : http://robots-txt.com/
If you just don't want google to access your particular page profile.php, You can ad this in robots.txt :
User-agent: Googlebot
Disallow: profile.php
And you can use classic links instead of JS ones, and add nofollow too :
<a href="./profile.php?id={$profile_id}" rel="nofollow">...</a>
You don't need to open it with JS
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.