View Full Version : Script to block external link to website

06-04-2007, 07:50 PM
Not sure if this is the right place for this question, but is there some script with which you can block links from specific websites to your website? Websites from which you would rather not be linked from? :rolleyes:

Thanks in advance,

06-04-2007, 08:17 PM
You can't prevent people from linking to your site, but you could probably use php to check the referrer header, and based on it, redirect them to somewhere else.

06-04-2007, 08:35 PM
.htaccess might be better for this. Create a file called htaccess.txt

Put this in it

order allow,deny
deny from .theirdomain.com
allow from all

Change theirdomain.com to the domain you wish to block, and then upload the file and rename it using your ftp program to .htaccess (no extension).

06-04-2007, 10:30 PM
Thanks for the replies. I wouldn't know how to do this - php to check the referrer header - and the htaccess doesn't seem to be working :(

The problem is with Wikipedia, the link to a subpage of my website that is then loaded outside the main page (inline frame).

This kind of vandalism (how else can you call ripping someone's work apart like that) is exactly the reason why I started using an inline frame with a "stay in frame" script, that in every other case seems to be working just fine (try to open a subpage in another window and you are redirected to the main page), but with Wikipedia it doesn't :confused: :mad:

What to do, what to do.....


06-04-2007, 10:54 PM
I see so they linked to your page that is supposed to be in a frame. I see you have tried to use javascript already. Can you post the wikipedia thats doing this? Can you not just remove the link? Wikipedias usually are editable.

06-04-2007, 11:14 PM
I've tried that, 10 minutes later the link was put back, deleted it again, explained why, then I got told to just go and delete my website if I didn't want to be linked from Wikipedia. I've send an email with a complaint to who ever is in charge of Wikipedia NL.

Meanwhile, could they be using some sort of script that overrules my script?

06-04-2007, 11:33 PM
I don't know which is why I asked you to post the wikipedia link to begin with.

06-05-2007, 08:00 AM
Yes, I forgot, sorry. Here's the link:


The 4th external link is to my website, or at least part of it.

06-05-2007, 08:38 AM
The javascript you tried has no effect on the document. Did you try writing that yourself? I suggest you use something that actually works. To explain what they are doing. This is your javascript

<script type="text/javascript">
if (top.location.href.indexOf("index.html") == -1){
top.location.href = "../index.html?teksten/deor.htm"
// -->
The only thing that is doing is looking for index.html in the url. If it finds it then nothing happens. The link they are using has ?index.html on it so the javascript you are using finds index.html so nothing happens. Try the script found here

06-05-2007, 10:38 AM
Hmm, that's odd. I didn't write it myself, I'm not a script writer. Someone from this forum pointed me to this script, if I am not mistaken. It comes together with a code in the main indexpage.

But I will try the script you gave this evening when I am back home.