• 0

.htaccess: Hotlinking Not Working


Question

Hey Guys,

 

So, I'm working on a few web projects, and I've come across people hotlinking files from my webhost to other sites. I'm trying to prevent that by setting up an htaccess file, but it seems to not be working.

Here's what I got.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)datascorner.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)hadesproject.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)faimindustry.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)project-gxs.com/.*$ [NC]
RewriteRule \.(gif|jpg|jpeg|bmp|zip|rar|mp3|flv|swf|xml|php|png|css|pdf|mp4|mkv)$ - [F]


RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)seedbox.datascorner.com/.*$ [NC]
RewriteRule \.(png|gif|jpg)$ http://www.seedbox.datascorner.com/one_piece_skull.png [R,L]

the top 3 domains are ones I own, and I'd like to be able to link between them. The 4th is a website I video encode for, and link files and upload images to share with others, so thats on there.

 

I'm struggling to figure this out, I've never messed with htaccess files before, so it's all new to me.


I used this site;

http://mediatemple.net/community/products/dv/204644230/prevent-hotlinking-with-a-htaccess-file

As an example; but I think I screwed up some where.

The Goal:

I want only the websites listed above, to be able to hotlink files from seedbox.datascorner.com, but any other websites get the one_piece_skull.png

To comply with NeoWin Policies, the files in that directory have been blocked. I'd rather not get banned.

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

It looks like you are combing two seperate things.  The first example given in your link prevents hot linking, the second replaces the image.  You can't do both.

 

I'm not the best at this, but I think you want something like this:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)seedbox.datascorner.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)datascorner.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)hadesproject.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)faimindustry.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)project-gxs.com/.*$ [NC]
RewriteRule \.(png|gif|jpg)$ http://www.seedbox.datascorner.com/one_piece_skull.png [R,L]
Link to comment
Share on other sites

  • 0

 

It looks like you are combing two seperate things.  The first example given in your link prevents hot linking, the second replaces the image.  You can't do both.

 

I'm not the best at this, but I think you want something like this:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)seedbox.datascorner.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)datascorner.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)hadesproject.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)faimindustry.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)project-gxs.com/.*$ [NC]
RewriteRule \.(png|gif|jpg)$ http://www.seedbox.datascorner.com/one_piece_skull.png [R,L]

 

That was close to it. I asked one of the guys I work with, and comments weren't done right.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.