PDA

View Full Version : Denying some websites linking to my site


Marpessa
10-18-2006, 10:13 PM
Hey everyone, newbie here.

I need help so badly! There's an awful site which always links to my site for everything and I wnat to deny the ip of the site, so I don't want people to come to my site through this site. So when they click on a link to my site on that site, their access will be denied.

I tried cpanels ip deny utility but it doesn't work. I need help immediately, I hope there's a way to do this.

oracleguy
10-18-2006, 11:18 PM
This is probably what you are looking for: http://www.javascriptkit.com/howto/htaccess14.shtml

Assuming your site is hosted using Apache. If it is IIS, you'll have to try something else, like using a server side language.

mlseim
10-19-2006, 12:47 AM
Check with your webhost.

My webhost, ipowerweb, and some others actually have a
"hot-linking" option that can be turned-off.

Marpessa
10-19-2006, 08:58 AM
Check with your webhost.

My webhost, ipowerweb, and some others actually have a
"hot-linking" option that can be turned-off.


yea but the thing is, they're not hotlinking, they're just linking to my site. But I want the visitors who came to my site through that link to be denied.

Help please? :(

CFMaBiSmAd
10-19-2006, 09:16 AM
The only way you can know where a visitor came from is if his browser provides the HTTP_REFERER header. The method at the link oracleguy provided (or if .htaccess is not available on your web server, doing the equivalent in PHP code in the pages on your web site) is the best available method. This will stop the casual visitor who clicks on a link and has a browser that provides the HTTP_REFERER. If someone really wants to bypass this (copy and past the link after closing and reopening the browser or browsing to a different site, then back to your site) or their browser does not provide the HTTP_REFERER information, there is nothing you can do to detect or stop them.

Edit: Any use of an IP address won't help as the IP information that will be available to you is the IP address of the visitor, not of the site that has a link on it.

Marpessa
10-19-2006, 09:26 AM
The only way you can know where a visitor came from is if his browser provides the HTTP_REFERER header. The method at the link oracleguy provided (or if .htaccess is not available on your web server, doing the equivalent in PHP code in the pages on your web site) is the best available method. This will stop the casual visitor who clicks on a link and has a browser that provides the HTTP_REFERER. If someone really wants to bypass this (copy and past the link after closing and reopening the browser or browsing to a different site, then back to your site) or their browser does not provide the HTTP_REFERER information, there is nothing you can do to detect or stop them.

Edit: Any use of an IP address won't help as the IP information that will be available to you is the IP address of the visitor, not of the site that has a link on it.


That sounds like exactly what I need! Can you please give me the exact code cause I don't know how to write codes in php. Thanks A LOT in advance!

Pennimus
10-20-2006, 01:24 AM
It's not PHP, it's htaccess. And the exact code was written in the link already provided : http://www.javascriptkit.com/howto/htaccess14.shtml

mlseim
10-20-2006, 02:55 AM
oh I see now ... I thought the issue was hot-linking ...

You can deny a referrer, but if they're that bad, they will be able
to spoof the referrer if they want. There are no guarantees when
it comes to viewing referrers. Perhaps they won't go through the
trouble of spoofing?

I would use PHP scripting.

Change the extension of your page to .php (example, "index.php" instead of "index.html")

Put this at the very top of your HTML:

<?php
// get referrer from _SERVER array
$ref = $_SERVER["HTTP_REFERER"];

// look for bad guys!
if ($ref == 'http://somespammydomain.biz')
{
//bad referrer detected, exit script
print "Access Denied";
exit;
}

// this part is to test out who the referrer is.
// Go to their site and click the link to yours.
// The echo line will print out what it sees ...
// note the referrer that is detected. Then,
// put that referrer in the URL above where it
// now says, "somespammydomain".
// Once set, remove the echo line ..

echo "Referrer Detected: $ref <br><br>";

//continue with your webpage
?>