Web Hosting Talk







View Full Version : Site Referrer


tarsius
05-11-2005, 10:17 PM
For example, I have a domain mydomain.com. Then another site somedomain.com points to my site mydomain.com. Somedomain.com used framesets so that my official site, mydomain.com, will not appear on the address bar.

How can I create a script that will check that if the referrer is somedomain.com, my site mydomain.com will override his frameset and will display instead at the address bar?

I created a PHP script by evaluating if http_referrer is equal to somedomain.com, then use header("Location: mydomain.com"). But the problem is somedomain.com will still appear on the address bar. :( I think header("Location:") creates a window on the parent window itself. :(

Is there another script to do this? I think this can be done using PHP.:)

Thanks.

ubernostrum
05-11-2005, 10:31 PM
Even better, why not drop in a bit of JavaScript to check whether your site is being displayed inside a frameset, and break out if it is? A quick Google search for "break frameset script" turns up some likely candidates, including this one (http://www.codelifter.com/main/javascript/framebuster1.html) which seems to be exactly what you need.

This way, if they get another domain or if another site starts doing the same thing, you dont' need to change anything.

orbitz
05-11-2005, 11:04 PM
yah, that's how i use it for some websites.

javascript will do ;)

BurstChris
05-12-2005, 12:44 AM
Location is a HTTP protocol header not specific to php, browsers redirect to that page and should update in the url bar.

Something else may be going on, like inside frames as people are talking about.

Cap'n Steve
05-12-2005, 01:22 AM
I believe using window.location='yoursite.com' in the body's onload event will override the frames. If not, the link attribute that you want is target="_top".

bloodyveins
05-12-2005, 02:12 AM
if you're using php, you shouldn't use the "location" header. instead use refresh.

header("Refresh: 1; url='http://url.ext'");

tarsius
05-12-2005, 02:55 AM
Thanks guys!

I used the javascript from the link given by ubernostrum and it perfectly worked!:)

here's the simple code for the info of the others::)
<script>

// (C) 2000 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this header

if (parent.frames.length > 0) {
parent.location.href = self.document.location
}


</script>

I will try also the PHP code by bloodyveins.:) thank again.