473,399 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

How do I prevent someone linking to my file?

So I have a file, which is a zip file I want to let people download.
But I don't want to let other sites link to my zip file -- I only want
people to be able to download the file by going through my site. I
know there are ways to prevent a file from being linked to if it's a
php page, but this isn't a php page, it's a zip file.

Any help would be tremendously appreciated. My apologies if this
isn't the appropriate newsgroup for this message.

George
Jul 20 '05 #1
5 2784
In post <e5*************************@posting.google.com>
George said...
So I have a file, which is a zip file I want to let people download.
But I don't want to let other sites link to my zip file -- I only want
people to be able to download the file by going through my site.


not possible but you can fool some people some of the time.

(assumes apache with appropriate setup) stick one of the below in a
..htaccess file[1] for the directory you want the directives to apply
to. child directories inherit the directives so if you stick it in
your root the directives will apply to all of your site.

#returns a HTTP 403 forbidden error
SetEnvIfNoCase Referer "^http://(www\.)?example.com" local_ref=1
<FilesMatch "\.(zip)">
# or "\.(zip|jpg|png|gif)" for images as well.
Order Allow,Deny
Allow from env=local_ref
</FilesMatch>

#returns a HTTP 403 forbidden error
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.com/.*$ [NC]
RewriteRule \.(zip)$ - [F]

#returns a substitute zip file (evil.zip) instead of the zip requested
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.com/.*$ [NC]
RewriteRule \.(zip)$ http://www.example.com/evil.zip [R,L]

all three check to see what the referer is and if its not your domain
returns the 403 (or substitute zip). the referer is easily faked or
not sent at all.

[1] a .htaccess file is a plain text file named as shown. if you
create the file with notepad save the file with quotes to prevent
notepad from adding a .txt extension i.e: ".htaccess"

a hash '#' indicates a comment line. remove/change/add them if you
wish.

--
29/September/2003 12:28:41 pm
Jul 20 '05 #2
br******@usenet.alt-html.org says...

George said...
So I have a file, which is a zip file I want to let people download.
But I don't want to let other sites link to my zip file -- I only want
people to be able to download the file by going through my site.


not possible but you can fool some people some of the time.


If you have access to PHP and a moderate degree of control over the web
server, you certainly can.

Put the file in a directory on the server outside the web document root.
No other site will be able to reach it, full stop.

Put a page inside your site which uses the file fpassthru function of
PHP (which can read server files outside the web document root) to
deliver the file to browsers.

Geoff M
Jul 20 '05 #3
In post <MP***********************@news.sbt.net.au>
Geoff Muldoon said...
I only want people to be able to download the file by going through my site.
not possible but you can fool some people some of the time.
If you have access to PHP and a moderate degree of control over the web
server, you certainly can.


read my follow up post where i corrected myself
--
29/September/2003 01:26:04 pm
Jul 20 '05 #4
"brucie" <br******@usenet.alt-html.org> schrieb im Newsbeitrag
news:12***************@alt-html.org...
read my follow up post where i corrected myself


Sorry where is the follow up post? Your .htaccess codes are very interesting
and I am also interested in the corrections.

--
Markus
Jul 20 '05 #5
In post <3f***********************@news.easynet.ch>
Markus Ernst said...
read my follow up post where i corrected myself
Sorry where is the follow up post?
obviously not on your newsserver :-) probably an issue on my end. long
story.
Your .htaccess codes are very interesting and I am also interested in the
corrections.


the correction was simply:

not possible with this method but....

--
29/September/2003 09:30:11 pm
Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: George Hernandez | last post by:
I have a site on a set of Linux Servers where my site is PHP enabled and I would like to prevent people from externally linking to content on my site and replace it with a warning image. I've...
6
by: Bill | last post by:
If I've got images in a directory, and I define that directory as an application directory (so I have a global.asa in it), what does my global.asa have to look like to prevent linking of images?
7
by: Steven T. Hatton | last post by:
Is there anything that gives a good description of how source code is converted into a translation unit, then object code, and then linked. I'm particularly interested in understanding why putting...
8
by: Smartin | last post by:
I have a form in Access97 which facilitates a query against a production Access database. Users will enter some search terms and see a datasheet view of the results in a subform. The prod table is...
7
by: wmkew | last post by:
Hello everyone I'm encountering a R6002 Runtime error and several bugs when trying to generate a simple Managed C++ application with .NET 2003. The main problem seems to arise from linking with...
0
by: Steve E. | last post by:
Hello, Similar to the post below, can you advise what I can do so "aspx" isn't appended when saving a file in Netscape 7? Big thanks in advance for tolerating a Netscape-related question - I'm...
18
by: Gleep | last post by:
I've searched google intensely on this topic and it seems noone really knows how to approch this. The goal I don't want clients to give out their usernames and passwords to friends, since the site...
0
by: xieml2007 | last post by:
Dear Madam or Sir, I encountered one problem which is quite similiar to the discussions launched at the web site: http://www.thescripts.com/forum/thread280324.html
1
by: tomlebold | last post by:
How do you prevent a user from linking an Access application to SQL Server tables?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.