View Full Version : restricting people linking from a certain site
happydoopwerty
10-02-2002, 11:40 PM
is there a way to restrict a site so that it is not possible for it to link to your own, in java? if not, what are my options?
happydoopwerty
10-02-2002, 11:55 PM
i figured out how to do it myself! yay!
martin_narg
10-03-2002, 12:09 AM
** good-ish news **
You could use history.length to find out if you are the first site that a specific browser has visited, although this would not solve your specific problem.
** bad news **
There's nothing to prevent people from linking to your site, it's how you deal with the requests when they come through. Using JavaScript isn;t an option as it would be a breach of the browser security model to read the url values contained in the history object, and hence there are no methods to read these values.
** solution **
The solution is to have your webserver block http requests from whichever domain you do not wished to be linked from. I've never tried asking a hosters for this, so I'm not sure what their reaction would be - if it is a business account then I'm sure the reaction would be very different from a home account.
Your hosting company may well have documentation available online, but a simple query to the technical team should satisfy any questions you have, and whether or not the hosters have a policy whereby they will do this.
Hope this helps
m_n
martin_narg
10-03-2002, 12:10 AM
I've just written a note as you posted yours ;) but i'd be interested to know how you got round this problem.
any chance of letting us know? :)
m_n
happydoopwerty
10-03-2002, 12:39 AM
well not really figured it out, more like a little bird got it from a code bank *-* well, at least i still know some java... lol
<script>
<!--
var invalidreferrals=new Array()
invalidreferrals[0]="angelfire.com"
invalidreferrals[1]="whatever."
var failed=0
for (r=0;r<invalidreferrals.length;r++){
if (document.referrer.indexOf(invalidreferrals[r])!=-1){
failed=1
break
}
}
if (failed>0){
alert("blah")
history.go(-1)
}
//-->
</script>
problem is, it doesnt work. i just want superficial blocking.. not hardcore total lockdown.. any solutions?
and btw.. "using resources" = "figuring it out by yourself" :o
martin_narg
10-03-2002, 01:14 AM
aaah *whaps his head* tis late, referrer *chuckle*
easy enuff to use providing the user has clicked on a link to get to ur site =)
whammy
10-03-2002, 01:20 AM
if(document.referrer.indexOf("yoursite.com") == -1){
window.location="http://www.barbie.com";
}
That will require them (allowing the user's browser has javascript enabled) to have navigated to your page from another page on your website (although it will also NOT allow direct browsing, since the referrer will then be blank).
Basically, if your website's name, i.e. "yoursite.com" is not in the URL they came from, it will send them to barbie.com - which will take care of most instances of direct linking. To get better security, you would probably need to look at the HTTP header sent from the client machine using a server-side language. :D
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.