Sounds like you can also use mod_rewrite, unless I'm missing something:
RewriteEngine On
RewriteRule ^link1.html$ http://www.domain.org [R=301,L]
RewriteRule ^link2.html$ http://www.domain.net [R=301,L]
Note that this would be a case-sensitive match, but if you want it to be case-insensitive, just add the "NC" flag after the "L" flag.
EDIT: Well, I guess I read your post wrong. What do you mean if the "referrer" is link1.html ? Are you saying that on link1.html and link2.html there are links to another page, and you're trying to redirect the user when they click on either of those links? OR are you saying that if they visit http://yoursite.com/link1.html they should be automatically redirected (as my code above does) ?