Gossamer Forum
Home : General : Perl Programming :

Stop people linking to your files...

(Page 1 of 2)
> >
Quote Reply
Stop people linking to your files...
Does anyone know of a script that stops people from linking directly to files on a site? I have quite a few large files on my site and don't want other sites linking directly to the files. Are there any scripts around that prevent this?

RedRum - I seem to remember you talking about this a while ago now but I can't remember the thread and can't find it via the search. Can you be of any assistance?

---------------
Cricket Web - http://www.cricketweb.net
Cricket Web Forum - http://forum.cricketweb.net/
---------------
Quote Reply
Re: [Philip_Clark] Stop people linking to your files... In reply to
You may be able to use Apache mod-rewrite... for example (which might not work... but should be close)

Code:
ReWriteEngine ON
RewriteCond %{REQUEST_URI} (zip|tar\.gz)$ [C]
RewriteCond %{HTTP_REFERER} !^http://(.+?\.)cricketweb.net
RewriteRule ^(.+)$ unauthorized.html [R]

--Philip
Links 2.0 moderator
Quote Reply
Re: [King Junko II] Stop people linking to your files... In reply to
Sorry but where should I put this?

---------------
Cricket Web - http://www.cricketweb.net
Cricket Web Forum - http://forum.cricketweb.net/
---------------
Quote Reply
Re: [Philip_Clark] Stop people linking to your files... In reply to
Oh yeah, that would be useful to know, wouldn't it? .htaccess or httpd.conf should work.

--Philip
Links 2.0 moderator
Quote Reply
Re: [King Junko II] Stop people linking to your files... In reply to
Is it possible to add more websites (permitted to link back) to the list - if so how?

thanks
Quote Reply
Re: [socrates] Stop people linking to your files... In reply to
One more question King Junko II.

Should I just create a ".htaccess" file with that in it and throw it in the root directory of my site?

---------------
Cricket Web - http://www.cricketweb.net
Cricket Web Forum - http://forum.cricketweb.net/
---------------
Quote Reply
Re: [socrates] Stop people linking to your files... In reply to
Sites that should be allowed to link directly to you can either be added to the!^domain.com or chained with additional conditions...
Code:
RewriteCond %{HTTP_REFERER} !^http://(.*\.)?(yoursite.com|theirsite.org)

or
Code:
RewriteCond %{HTTP_REFERER} !^http://(.*\.)?somedomain\.com [C]
RewriteCond %{HTTP_REFERER} !^http://(.*\.)?anotherdomain\.com [C]

you may want to look at the mod_rewrite docs at apache.org for better (and hopefully accurate) examples. I've learned a little from http://www.modrewrite.com.

If you're going to be having a lot of allowed referers, I would suggest using the mapping function through an external program. Some examples are provided in Ralf Engleschall's guide I think.

--Philip
Links 2.0 moderator
Quote Reply
Re: [King Junko II] Stop people linking to your files... In reply to
Code:
ReWriteEngine ON
RewriteCond %{REQUEST_URI} (zip|tar\.gz)$ [C] RewriteCond %{HTTP_REFERER} !^http://(.+?\.)cricketweb.net
RewriteRule ^(.+)$ unauthorized.html [R]

The code you provided me doesn't work. I placed in in an ".htaccess" and an "httpd.conf" file but it didn't work. Unsure

I placed those files in the root directory of my site. Any other ideas?

---------------
Cricket Web - http://www.cricketweb.net
Cricket Web Forum - http://forum.cricketweb.net/
---------------

Last edited by:

Philip_Clark: Feb 26, 2002, 9:12 PM
Post deleted by Philip_Clark In reply to
Quote Reply
Re: [Philip_Clark] Stop people linking to your files... In reply to
Sorry... that could mean one many things... including
a) my example is buggy
b) your host does not have rewrite installed/turned on
c) your host does not allow you ot override global settings with .htaccess

Please check the documentation and search this forum... this has been discussed before.

--Philip
Links 2.0 moderator
Quote Reply
Re: [King Junko II] Stop people linking to your files... In reply to
Thanks Philip.

For those interested I've just come across these three pages that should prove useful:

http://faq.solutionscripts.com/misc/hot_linking.html

http://www.webhostingtalk.com/...s=&threadid=3065

http://www.gossamer-threads.com/...h%20stealing;#155672

I'm going to give those a go tonight - figures crossed!

---------------
Cricket Web - http://www.cricketweb.net
Cricket Web Forum - http://forum.cricketweb.net/
---------------

Last edited by:

Philip_Clark: Feb 27, 2002, 1:15 PM
Quote Reply
Re: [Philip_Clark] Stop people linking to your files... In reply to
Damn Unsure

I tried:



RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://www.cricketweb.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.cricketweb.net/.*$ [NC]
RewriteRule .*\.(gif|GIF|jpg|JPG|zip|ZIP|exe|EXE)$ - [F]


from that first link I added but it didn't work. I placed the .htaccess file in the root directory of my site but it just locked down my whole site.

I sent Terabyte (my host) an email and got this in reply

Quote:


4U plans (like yours) do have mod_rewrite. It is not something we support
however. You are welcome to try to set it up if you wish.




Any ideas guys?

---------------
Cricket Web - http://www.cricketweb.net
Cricket Web Forum - http://forum.cricketweb.net/
---------------
Quote Reply
Re: [Philip_Clark] Stop people linking to your files... In reply to
Guys! help - please! Pirate

---------------
Cricket Web - http://www.cricketweb.net
Cricket Web Forum - http://forum.cricketweb.net/
---------------
Quote Reply
Re: [Philip_Clark] Stop people linking to your files... In reply to
^

---------------
Cricket Web - http://www.cricketweb.net
Cricket Web Forum - http://forum.cricketweb.net/
---------------
Quote Reply
Re: [Philip_Clark] Stop people linking to your files... In reply to
See: http://httpd.apache.org/...sc/rewriteguide.html and Blocked Inline Images section.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Stop people linking to your files... In reply to
Thanks for the link Alex.

I've tried and tried over the past couple of days to get it working and just can't. This is driving me crazy! Crazy Unsure

---------------
Cricket Web - http://www.cricketweb.net
Cricket Web Forum - http://forum.cricketweb.net/
---------------

Last edited by:

Philip_Clark: Mar 3, 2002, 3:53 PM
Quote Reply
Re: [Philip_Clark] Stop people linking to your files... In reply to
Have you got any rewrites to work, just to check they are functioning properly?

Last edited by:

RedRum: Mar 3, 2002, 4:11 PM
Quote Reply
Re: [RedRum] Stop people linking to your files... In reply to
Thanks for your response RedRum.

No I haven't managed to get any working I don't think although how can I tell what it does work?

Tera-byte support gave me this response so surely it will work some how:

Quote:
4U plans (like yours) do have mod_rewrite. It is not something we support
however. You are welcome to try to set it up if you wish.

---------------
Cricket Web - http://www.cricketweb.net
Cricket Web Forum - http://forum.cricketweb.net/
---------------
Quote Reply
Re: [Philip_Clark] Stop people linking to your files... In reply to
Try something like:

RewriteRule ^.* http://www.someurl.com/ [L]

...on its own.
Quote Reply
Re: [RedRum] Stop people linking to your files... In reply to
Thanks Redrum Smile

Should I save it as a .htaccess file or a httpd.conf file?

---------------
Cricket Web - http://www.cricketweb.net
Cricket Web Forum - http://forum.cricketweb.net/
---------------
Quote Reply
Re: [Philip_Clark] Stop people linking to your files... In reply to
Try htaccess, if that doesn't work try httpd.conf......hm....is this a dedicated server?
Quote Reply
Re: [RedRum] Stop people linking to your files... In reply to
Thanks a lot Redrum - worked perfectly with httpd.conf Cool

The people on the other website now get "file not found" errors Angelic

What can I do to add more addresses to the file though?

---------------
Cricket Web - http://www.cricketweb.net
Cricket Web Forum - http://forum.cricketweb.net/
---------------
Quote Reply
Re: [Philip_Clark] Stop people linking to your files... In reply to
Also, is there anything I can do to automatically redirect them to a page saying "please don't steal my bandwidth, etc" rather than a "file not found - 404" page?

---------------
Cricket Web - http://www.cricketweb.net
Cricket Web Forum - http://forum.cricketweb.net/
---------------
Quote Reply
Re: [Philip_Clark] Stop people linking to your files... In reply to
Just change www.someurl.com with your custom page url.

I did provide it just as a test though to check rewrites worked, it wasn't a solution to your question....but hey if it works like you want then thats cool.

Last edited by:

RedRum: Mar 6, 2002, 2:46 AM
Quote Reply
Re: [RedRum] Stop people linking to your files... In reply to
I've changed it to:

Quote:


RewriteRule ^.* http://www.cricketweb.net/ [L]


but when I click on a download link on another website it still brings up a file not found error. Any ides why?

---------------
Cricket Web - http://www.cricketweb.net
Cricket Web Forum - http://forum.cricketweb.net/
---------------
> >