You can use PHP:
< ?php if ($_SERVER['REQUEST_URI'] == '/affiliate') { ?>
< ?php } ?>
forget the javascript, the code must be in the page source bots do not execute javascript (actually they do but I doubt the nofollow is evaluated if added via javascript).
Stefano.