hey, i run a proxy using phproxy 0.52beta and im trying to code into it a way to redirect all people who dont come from the index page while trying to surf, to the index page. Ive tried the following in PHP: $md5 = $_POST["v"]; $date =date("m.d.y H"); $dt = md5($date); if($md5 != $dt) { header("Location: http://www.radicaloverthrow.com/"); }; This is in the surf page i md5 the current date and pass it along in a hidden value with the surf form then check if it is the same and if it isnt redirect however its not working. So is there a way to do it with PHP or htaccess or something?
why not set a session variable on your homepage, then in your header (included in all pages) do a redirect if the session variable isn't set (make sure to do the check AFTER you set the session variable on the homepage)
Great idea ccoonen (y), but it will be valid for one time. Unless you unregister this variable at the end of every page.
It should be pretty easy. First use split or stripslashes (however in php) to get rid of all the slashes (/) in the $_SERVER['HTTP_REFERER']. Then take out the www. and name the result $referer. Then: $allowed = your-site.com; if($referer != $allowed) { header("Location: http://www.radicaloverthrow.com/"); }; I warn you I don't know much php. But I have seen something like this done before.
ccoonen's idea is the way to go. $_SERVER['HTTP_REFERER'] isn't that reliable anyway. Set the session var on the index page and redirect from other pages if the var isn't set. Simple, easy, elegant. Way to go, ccoonen.