Page 1 of 1

Custom Global Redirect

Posted: Mon Mar 15, 2004 11:05 am
by tFreeman
Hi, I have a situation here where I have about 20 links leading to external sites, I have to make a standard page that will come up alerting visitors that the link they've click is taking them to another site. I imagine the redirect page would be good in php where the url for the "continue" button is equal to some variable set by the link that sent them to the page, but I dont know much about php and Im not sure how to go about this or maybe Im looking at the whole problem wrong, any help would be very much appreciated, thank you in advance.

Posted: Mon Mar 15, 2004 11:36 pm
by tFreeman
The more I google up on this the more confused I get, every single person who has asked this question has been ignored so either there is something fundamentaly impossible about this I dont see or its something simple but either way Im completly stumped. On my redirect.htm page I tried

<a href= http://path/to/redirect.php?target=varUrl>>Variable link</a>

the contents of redirect.php was

<?php
header(location: _request['target']);
exit;
?>

I cant get varUrl to ever equal anything meaningful, I want the sending link to set that value, can I do this or am I just wasting very value time?

Posted: Tue Mar 16, 2004 12:49 am
by markl999
Here's a test that worked for me ok.

Code: Select all

<!-- redirect.html -->
<a href="/redirect.php?varUrl=http://google.com">google</a>

Code: Select all

//redirect.php
<?php
header("Location: ".$_GET['varUrl']);
exit;
?>

Posted: Tue Mar 16, 2004 8:34 am
by tFreeman
That works for me too but i need varUrl to be set by the sending link thats why I was trying to get varUrl=someOtherVar to work. Thanks for your reply

Posted: Wed Mar 17, 2004 3:34 am
by tFreeman
I finally got it with a tiny bit of hand-sewn javascript

link that leads to external site is coded like:

<a href="http://www.mySite.com/redirect.htm?xurl ... .com">link to external site</a>

then for redirect.htm I have my disclaimer page I made except I added to the head:

<script language=javascript>
function setLink(xurl){
xurl=document.location.search.substring(6);
window.open(xurl)
}
</script>

and finally made the link for the continue button

<a href="javascript:setLink();">continue</a>

this was almost too simple and works fine for those of you like me who need something simple but don't know how to ask ,I give you my mammoth creation and please send me 1200$ if you plan to use this or you could just curse me under your breath thats fine too.