Daleeburg Posted May 18, 2007 Share Posted May 18, 2007 First off, yes, I do realize this is a PHP forum, but the users around here seem to be very well rounded and I honestly dont have a clue when it comes to javascript, so if i went to a javascript forum they would all laugh at me and i would feel like and uber noob. so with that said, please dont rip into me about posting this on a PHP forum. I am trying to have it so that if someone comes from somthing like, www.site.com/xxxx/yyyy they end up at www.mysite.com/folder/xxxx/yyyy.html I found a piece of java that works for one set page to one set page, but since this site is going to be constantly changing, i really need to have the script set up with vairbles. <SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT"> <!-- Hide script from old browsers<br> if (document.referrer = "http://www.referringPageName.html") location.href = "yourPage.html"; //-- Stop hiding script --> </SCRIPT> If anybody knows enough about javascript that they could tell me how to do this, it would be greatly appreciated. ~D Quote Link to comment https://forums.phpfreaks.com/topic/52019-a-javascript-question/ Share on other sites More sharing options...
taith Posted May 18, 2007 Share Posted May 18, 2007 boo javascript! lol okok... it has its uses... one of which, isnt automated redirects... <? function get_referrer(){ return (!$ref=@$HTTP_REFERER) ? $_SERVER['HTTP_REFERER'] : $ref; } switch(get_referrer()){ case "http://www.google.com": header('Location: google.php'); break; } exit; ?> Quote Link to comment https://forums.phpfreaks.com/topic/52019-a-javascript-question/#findComment-256387 Share on other sites More sharing options...
Daleeburg Posted May 18, 2007 Author Share Posted May 18, 2007 sweet, didnt thing you could do that in php I have seen the light But i am a little lost on that php, Is there a way to tie variables into that so that it would look at the refering and kick you out to the spot on the current web? ~D Quote Link to comment https://forums.phpfreaks.com/topic/52019-a-javascript-question/#findComment-256390 Share on other sites More sharing options...
taith Posted May 18, 2007 Share Posted May 18, 2007 eh? Quote Link to comment https://forums.phpfreaks.com/topic/52019-a-javascript-question/#findComment-256391 Share on other sites More sharing options...
per1os Posted May 18, 2007 Share Posted May 18, 2007 The main problem with referrer is that it is un-reliable. But if I am understanding you right, maybe this will help: <?php function get_referrer(){ return (!$ref=@$HTTP_REFERER) ? $_SERVER['HTTP_REFERER'] : $ref; } $referrer = get_referrer(); header("Location: " . $referrer); ?> Quote Link to comment https://forums.phpfreaks.com/topic/52019-a-javascript-question/#findComment-256397 Share on other sites More sharing options...
taith Posted May 18, 2007 Share Posted May 18, 2007 in 2 years, i've never had any issues with my referrer script... and if you just want an unreachable page... just... header('Location: '.get_referrer()); Quote Link to comment https://forums.phpfreaks.com/topic/52019-a-javascript-question/#findComment-256398 Share on other sites More sharing options...
per1os Posted May 18, 2007 Share Posted May 18, 2007 If you want proof, go and grab flashget or some similiar program, change the referrer to anything you want and request your page. Or you can also disallow that information to be kept via the browser. Just a word of caution, it works for the most part, but not everyone has the referrer set, or they have set to one thing as to never give out where they have been. Fun stuff the world of the internet. EDIT http://www.stardrifter.org/refcontrol/ Just found that extension for Firefox. Broken sites - Some sites perform misguided referrer checks in the name of "security". These checks don't add any real security since the referrer is easily faked and can often cause problems when the browser's behavior changes. You can configure RefControl to send these sites whatever they are expecting and work around this kind of problem. Fun - Send humorous things, secure in the knowledge that they are being written into the server's log file for the amusement of anyone who might later discover them there. Ok, maybe that's not much fun, but RefControl will let you do it anyway. Quote Link to comment https://forums.phpfreaks.com/topic/52019-a-javascript-question/#findComment-256399 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.