|
|
Allow hot linking via referrer from specific domains
Allow hot linking to your images by creating a defined list of Good Referrers (or known good domains) by using .htaccess with RewriteRules.
- Ensure that the following parameters have been enabled within the apache configuration.
Options FollowSymLinks
AllowOverride FileInfo AuthConfig Limit
- If you have a separate configuration for your "images" and "htdocs" directory be sure to enable the above features in each section otherwise the .htaccess will not work.
< Directory "/web/www_root/images">
Options FollowSymLinks
AllowOverride FileInfo AuthConfig Limit
Order allow,deny
Allow from all
< /Directory>
< Directory "/web/www_root/htdocs">
Options FollowSymLinks
AllowOverride FileInfo AuthConfig Limit
Order allow,deny
Allow from all
< /Directory>
- Restart the webserver
./apachectl restart
- Create an .htaccess file within your "images" directory structure. Replace "domain.com" with your domain name.
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://www\.domain\.com [NC]
RewriteCond %{HTTP_REFERER} !^$ [NC]
RewriteRule \.(jpe?g|gif|bmp|png)$ images/bad.gif [L]
- RewriteEngine On
If the "RewriteEngine" is not enabled these policies will not work.
- RewriteCond %{HTTP_REFERER} !^http://www\.domain\.com [NC]
The above checks to see if the client is from your own domain. If not then the second "RewriteCond" takes effect
- RewriteCond %{HTTP_REFERER} !^$ [NC]
The above checks to see if the client accessed your site directly.
- RewriteRule \.(jpe?g|gif|bmp|png)$ images/bad.gif [L]
If none of the "RewriteCond" conditions match then the client will be served the "bad.gif" image.
- If you have multiple domains which are allowed to use your images, be sure to include those domains in the policy otherwise they will all get the "bad.gif" image.
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://www\.yahoo\.com [NC]
RewriteCond %{HTTP_REFERER} !^http://www\.google\.com [NC]
RewriteCond %{HTTP_REFERER} !^http://www\.domain\.com [NC]
RewriteCond %{HTTP_REFERER} !^$ [NC]
RewriteRule \.(jpe?g|gif|bmp|png)$ images/bad.gif [L]
- RewriteCond %{HTTP_REFERER} !^http://www\.yahoo\.com [NC]
- RewriteCond %{HTTP_REFERER} !^http://www\.google\.com [NC]
These lines indicate that "www.yahoo.com" and "www.google.com" are within your good list and that they are able to hot link to your image.
|
|
|