Created
February 15, 2012 00:03
-
-
Save alchemycs/1831823 to your computer and use it in GitHub Desktop.
Apache config for restricting images based on referrer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This stops others from using simple links to your media on their site. See comments at end of GIST for limitations | |
# Prevents sites you don't own placing simple embeds on those sites. eg <img src="http://example.com/images/sample-image.png"/> | |
RewriteCond %{REQUEST_URI} ^/images/.* | |
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.com(/)?.*$ [NC] | |
RewriteRule .* - [F] | |
# Your bandwidth is precious and others shouldn't poach your bandwidth. | |
# - If someone wants to use media you have on the internet they can get it one way or another | |
# - Does not protect against spoofed headers | |
# - Doesn't stop people from right-click > download image/file (etc) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
Ok, someone mentioned to me that this will deny SSL sites. I thought that was kind of obvious, so here are some more usage notes:
/images/
on line 3 is an actual path to a folder off your document root you want this to apply tohttp
on line 4 ishttps
if you have an SSL siteexample.com
to reflect the domain your configuration is hosting forI think that's it :)