An affiliate ID used for tracking purposes can be considered similar to a session ID, in that different affiliate links can lead to the same page and content, thus resulting in duplicate content.
Therefore to disallow affiliate links from being crawled (resulting in duplicate content), from the "Pattern matching" section in Google Webmaster Tools - Block or remove pages using a robots.txt file:
The Disallow: / *? directive will block any URL that includes a ?
(more specifically, it will block any URL that begins with your domain
name, followed by any string, followed by a question mark, followed by
Even more specific to URL's with
?id= in them, you could simply have:
If the affiliate links redirect to custom affiliate pages with similar content, you should specify a canonical URL in these pages to point to the preferred version of the page you want indexed. For more on this, see: Google Webmaster Tools - About rel="canonical"
The "nowfollow" attribute in rel="nofollow" tells search engines not to follow the links on a page, or don't follow this specific link, which isn't necessary if you're blocking them in your robots.txt. As Google indicates, this gives webmasters more "granular control" to tell robots not to crawl specific links or pages.