Apache – deny access by referrer

Create .htaccess file in main (root) directory of your webserver/website with following content:

RewriteEngine On
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} firstdomain\.net [NC,OR]
RewriteCond %{HTTP_REFERER} anotherdomain\.com
RewriteRule .* - [F]