hot link protection via htaccess (X, Y, and all, but with safe list)


President-Anonymous
 Share

Recommended Posts

I've hit a wall....

The Goal

Block site X and show them image X

Blocked site Y and show them image Y

Block everyone else and show them image Z

Have a safe list / white list, so that I can still hot link here on XenForo and a few other select sites.

What Jake came up with (but doesn't seem to work)


# NO HOTLINK FOR SITE X
RewriteCond %{HTTP_REFERER} ^http://(www\.)?sitex\.com [NC]
RewriteCond %{REQUEST_URI} !nohotlinkingx\.jpg$ [NC]
RewriteRule \.(jpg|gif|jpeg|png|bmp|pdf|zip|txt|svg)$ http://www.yoursite.com/nohotlinkingx.jpg? [NC,L]

RewriteCond %{HTTP_REFERER} ^http://(www\.)?sitex\.com [NC]
RewriteRule ^attachments/.+$ http://www.yoursite.com/nohotlinkingx.jpg? [NC,L]

# NO HOTLINK FOR SITE Y
RewriteCond %{HTTP_REFERER} ^http://(www\.)?sitey\.com [NC]
RewriteCond %{REQUEST_URI} !nohotlinkingy\.jpg$ [NC]
RewriteRule \.(jpg|gif|jpeg|png|bmp|pdf|zip|txt|svg)$ http://www.yoursite.com/nohotlinkingy.jpg? [NC,L]

RewriteCond %{HTTP_REFERER} ^http://(www\.)?sitey\.com [NC]
RewriteRule ^attachments/.+$ http://www.yoursite.com/nohotlinkingy.jpg? [NC,L]

# NO HOTLINK FOR ALL SITES
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yoursite\.com [NC]
[COLOR=red]RewriteCond %{HTTP_REFERER} !^http://(www\.)?allowedsite\.com [NC][/COLOR]
RewriteCond %{REQUEST_URI} !nohotlinking\.jpg$ [NC]
RewriteRule \.(jpg|gif|jpeg|png|bmp|pdf|zip|txt|svg)$ http://www.yoursite.com/nohotlinking.jpg? [NC,L]

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yoursite\.com [NC]
[COLOR=red]RewriteCond %{HTTP_REFERER} !^http://(www\.)?allowedsite\.com [NC][/COLOR]
RewriteRule ^attachments/.+$ http://www.yoursite.com/nohotlinking.jpg? [NC,L]
[/code]

I know someone here must have done this before.

Can anyone here tell me what is wrong with this code?

(If you don't have the answer... Please like this post knowing that I wasn't someone who opened up a wasteful support ticket. I imagine that happens a lot.)

Link to comment
Share on other sites

Well it's official. I don't know how to do a rich text code in ipb. so basic code will have to do

# NO HOTLINK FOR SITE X

RewriteCond %{HTTP_REFERER} ^http://(www\.)?sitex\.com [NC]

RewriteCond %{REQUEST_URI} !nohotlinkingx\.jpg$ [NC]

RewriteRule \.(jpg|gif|jpeg|png|bmp|pdf|zip|txt|svg)$ http://www.yoursite.com/nohotlinkingx.jpg? [NC,L]


RewriteCond %{HTTP_REFERER} ^http://(www\.)?sitex\.com [NC]

RewriteRule ^attachments/.+$ http://www.yoursite.com/nohotlinkingx.jpg? [NC,L]


# NO HOTLINK FOR SITE Y

RewriteCond %{HTTP_REFERER} ^http://(www\.)?sitey\.com [NC]

RewriteCond %{REQUEST_URI} !nohotlinkingy\.jpg$ [NC]

RewriteRule \.(jpg|gif|jpeg|png|bmp|pdf|zip|txt|svg)$ http://www.yoursite.com/nohotlinkingy.jpg? [NC,L]


RewriteCond %{HTTP_REFERER} ^http://(www\.)?sitey\.com [NC]

RewriteRule ^attachments/.+$ http://www.yoursite.com/nohotlinkingy.jpg? [NC,L]


# NO HOTLINK FOR ALL SITES

RewriteCond %{HTTP_REFERER} !^$

RewriteCond %{HTTP_REFERER} !^http://(www\.)?yoursite\.com [NC]

[COLOR=red]RewriteCond %{HTTP_REFERER} !^http://(www\.)?allowedsite\.com [NC][/COLOR]

RewriteCond %{REQUEST_URI} !nohotlinking\.jpg$ [NC]

RewriteRule \.(jpg|gif|jpeg|png|bmp|pdf|zip|txt|svg)$ http://www.yoursite.com/nohotlinking.jpg? [NC,L]


RewriteCond %{HTTP_REFERER} !^$

RewriteCond %{HTTP_REFERER} !^http://(www\.)?yoursite\.com [NC]

[COLOR=red]RewriteCond %{HTTP_REFERER} !^http://(www\.)?allowedsite\.com [NC][/COLOR]

RewriteRule ^attachments/.+$ http://www.yoursite.com/nohotlinking.jpg? [NC,L]

Link to comment
Share on other sites

Well.... Still not working..... Given up on using more than 1 photo and so I tried this...

# hotlink protection allowing for multiple domains
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://([^.]+\.)?sociallyuncensored\. [NC]
RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
RewriteCond %{HTTP_REFERER} !google\. [NC]
RewriteCond %{HTTP_REFERER} !bing\. [NC]
RewriteCond %{HTTP_REFERER} !yahoo\. [NC]
RewriteCond %{REQUEST_URI} !^/hotlink\.jpg$ [NC]
RewriteRule \.(gif|jpg|png)$ http://www.sociallyuncensored.eu/hotlink.jpg [R,NC,L][/php]

No luck. :(

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share