473,387 Members | 2,436 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,387 software developers and data experts.

Need Help to prevent external linking

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 researched the following to put in an .htaccess file on teh root of my
server, but none of the methods or changes or suggestions I've found on the
web work...
================================================== ==========
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://www.mydomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://mydomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://anothermydomain/.*$ [NC]
RewriteRule .*\.jpeg$ - [F]
RewriteRule .*\.jpg$ - [F]
RewriteRule .*\.zip$ - [F]

RewriteCond %{HTTP_REFERER} !^$
RewriteRule ^URL_of_my_warning_image.jpg$ - [F]
================================================== ==========

that is all I have in teh .htaccess file that sits at the root of my server,
but no matter what, if I type in a URL leading to content on my site
architecture, the warning image does not display - the file that was
requested is given. I want to force people to have to be at my site to be
able to view the images or download the zip files.

Please help.
Thanks.
Jul 17 '05 #1
7 2164
On Fri, 23 Jul 2004 02:24:59 +0000, George Hernandez wrote:
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.

[ snip ]
Other than this has nothing to do with PHP, the short and bitter truth
answer is, you can't =)

Regards,

Ian

--
Ian.H
digiServ Network
London, UK
http://digiserv.net/

Jul 17 '05 #2
"George Hernandez" <no_email@no_domain.pud> wrote in message
news:%F****************@news4.srv.hcvlny.cv.net...
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 researched the following to put in an .htaccess file on teh root of my server, but none of the methods or changes or suggestions I've found on the web work...

-snip-

You have set RewriteEngine On?

Check your server is processing .htaccess files by setting up a password
protected directory.

Jul 17 '05 #3
"George Hernandez" <no_email@no_domain.pud> wrote in message
news:%F****************@news4.srv.hcvlny.cv.net...
that is all I have in teh .htaccess file that sits at the root of my server, but no matter what, if I type in a URL leading to content on my site
architecture, the warning image does not display - the file that was
requested is given. I want to force people to have to be at my site to be
able to view the images or download the zip files.


It is a lot o fwork, but you could serve all images and zips from, php
scripts. so instead of using <img src="img17.gif"> you would be using
something like <img src="img.php?imgId=17"> . Now img.php would send
appropriate header, and then stream (from protected location) image byte
stream. Also when img.php could for instance check the referer field, and
stream "not allowed" image. Problem with referer is that browser does not
have to send it, so some of "leagal users" would not be able to see your
images. Another solution is to have (time limited) session ids given with
each request for image, something like <img
src="img.php?imgId=17&sessionId=098989DDAJK">. If sessionId is not valid,
no image. Or you could combine the two methods.

rush
--
http://www.templatetamer.com/
Jul 17 '05 #4
"CJ Llewellyn" <sa****@tmslifeline.com> wrote in message news:<cd**********@slavica.ukpost.com>...
"George Hernandez" <no_email@no_domain.pud> wrote in message
news:%F****************@news4.srv.hcvlny.cv.net...
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 researched the following to put in an .htaccess file on teh root of

my
server, but none of the methods or changes or suggestions I've found on

the
web work...

-snip-

You have set RewriteEngine On?

Check your server is processing .htaccess files by setting up a password
protected directory.


what means "externally linking into your page"? i think you mean using
your pages as part of someone elses site. if that is the case and you
are using a frameset there is a quite simple javascript solution. just
have every html doc check the frameset it's opened in by with

top.document.id

so if the id of the topmost frame is not the one of your own frameset,
you can have javascript perform some action

micha
Jul 17 '05 #5

"rush" <pi**@rush.avalon.hr> wrote in message
news:cd**********@ls219.htnet.hr...
"George Hernandez" <no_email@no_domain.pud> wrote in message
news:%F****************@news4.srv.hcvlny.cv.net...
that is all I have in teh .htaccess file that sits at the root of my

server,
but no matter what, if I type in a URL leading to content on my site
architecture, the warning image does not display - the file that was
requested is given. I want to force people to have to be at my site to be able to view the images or download the zip files.


It is a lot o fwork, but you could serve all images and zips from, php
scripts. so instead of using <img src="img17.gif"> you would be using
something like <img src="img.php?imgId=17"> . Now img.php would send
appropriate header, and then stream (from protected location) image byte
stream. Also when img.php could for instance check the referer field, and
stream "not allowed" image. Problem with referer is that browser does not
have to send it, so some of "leagal users" would not be able to see your
images. Another solution is to have (time limited) session ids given with
each request for image, something like <img
src="img.php?imgId=17&sessionId=098989DDAJK">. If sessionId is not valid,
no image. Or you could combine the two methods.

rush
--
http://www.templatetamer.com/


In my experience, image files served with this method are not cached by the
browser, which can be frustrating for the user.

RU
Jul 17 '05 #6

"rush" <pi**@rush.avalon.hr> wrote in message
news:cd**********@ls219.htnet.hr...
"George Hernandez" <no_email@no_domain.pud> wrote in message
news:%F****************@news4.srv.hcvlny.cv.net...
that is all I have in teh .htaccess file that sits at the root of my

server,
but no matter what, if I type in a URL leading to content on my site
architecture, the warning image does not display - the file that was
requested is given. I want to force people to have to be at my site to be able to view the images or download the zip files.


It is a lot o fwork, but you could serve all images and zips from, php
scripts. so instead of using <img src="img17.gif"> you would be using
something like <img src="img.php?imgId=17"> . Now img.php would send
appropriate header, and then stream (from protected location) image byte
stream. Also when img.php could for instance check the referer field, and
stream "not allowed" image. Problem with referer is that browser does not
have to send it, so some of "leagal users" would not be able to see your
images. Another solution is to have (time limited) session ids given with
each request for image, something like <img
src="img.php?imgId=17&sessionId=098989DDAJK">. If sessionId is not valid,
no image. Or you could combine the two methods.

rush
--
http://www.templatetamer.com/


Also, 'from protected location' would mean the password box popping up
everytime the user loaded the page with that img src.

RU
Jul 17 '05 #7
.oO(George Hernandez)
that is all I have in teh .htaccess file that sits at the root of my server,
but no matter what, if I type in a URL leading to content on my site
architecture, the warning image does not display - the file that was
requested is given.
If you directly type in an URL in the address bar there's _no_ referrer
header sent to the server, so the script can't block the access.
RewriteRule .*\.jpeg$ - [F]
RewriteRule .*\.jpg$ - [F]
Shorter: RewriteRule .*\.jpe?g - [F]
I want to force people to have to be at my site to be
able to view the images or download the zip files.


Hotlink-blockers rely on referrer information and will work in most
cases, but you can't really prevent it to 100%.

Micha
Jul 17 '05 #8

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

Similar topics

8
by: Johnny Knoxville | last post by:
I've added a favicon to my site (http://lazyape.filetap.com/) which works fine if you add the site to favourites the normal way, but I have some JavaScript code on a couple of pages with a link,...
0
by: Ida | last post by:
Hi, I am trying to build an dll with Microsoft Visual C++ but during the linking phase I get linking errors. Script.obj : error LNK2019: unresolved external symbol __imp__PyString_AsString...
3
by: We need more power captain | last post by:
Hi, I know less than a noob, I've been asked to do some compiles in VC++ 6 without knowing too much at all. (I'm a COBOL program normally so this is all too much for me) I open VC++6, open...
2
by: Freddy | last post by:
I am not an experienced programmer, but I had a VC++ program I am trying to eliminate all the VC++ commands from it...and keeping it as a normal C/C++ program......I guess I have succeeded so far,...
2
by: Sara | last post by:
Hi - I've been reading the posts for a solution to my query, and realize that I should ask an "approch" question as well. We receive our production data from a third party, so my uers import...
5
by: Joerg M. Colberg | last post by:
My apologies if this is a trivial problem. I have been trying to solve this for a few days now and I just can't get it done. Here's what I have. I have a C++ project in VisualStudio.NET whose code...
2
by: Ian Taite | last post by:
Help, I am trying to nail a linking problem, to avoid having to lose about 2 weeks work. I have a backup of my project that compiles and links OK however changes I made sometime since then have...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
0
by: dotyet | last post by:
Hi Everyone, I am trying to build a DB2 UDB UDF which can perform regex over the table data. The user defined function will call an external .dll file to do the task. I am referring to the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.