I'd like to use the header php function
to redirect to any given url.
But I ran into a problem. Check this:
My link.html code is simply this:
<?php
$link = $_GET['pg'];
header("Location: $link");
?>
<html>
<p><a href="<?=$link?>">Click Here</a></p>
</html>
Oughta work, eh?
But when I use this URL:
http://www.americanprogressaction.org/s ... ct=2026855
in a call like this:
http://www.webwisesage.com/link.html?pg ... ct=2026855
it gets a bad page address, whereas the page at the url is fine!
Any ideas?
...Vidya
http://www.webwisesage.com
header php function challenge
Moderator: General Moderators
- nickman013
- Forum Regular
- Posts: 764
- Joined: Sun Aug 14, 2005 12:02 am
- Location: Long Island, New York
Not it
The site has an .htaccess set so that all html pages are treated as PHP pages.
And yes, I want to redirect users instantly.
Doesn't matter what code is below the header function.
Eventually, it will be statistic gathering.
Thanks
...Vidya
And yes, I want to redirect users instantly.
Doesn't matter what code is below the header function.
Eventually, it will be statistic gathering.
Thanks
...Vidya
- nickman013
- Forum Regular
- Posts: 764
- Joined: Sun Aug 14, 2005 12:02 am
- Location: Long Island, New York
Here's the atual reason it didn't work
I found out why it wasn't working.
When you have:
http://www.somedomain.com/link.html?pg= ... ct=2026855
where the link.html routine is doing a GET on the pg variable, the GET[pg] variable
is actually only http://www.americanprogressaction.org/s ... =klLWJcP7H
There's also a GET variable that is 1331575
and a GET[ct] that is 2026855
You can't just redirect to GET[pg]
You have to reassemble all the GET variables (using foreach)
and then redirect.
Simple when you see it!
....Vidya
When you have:
http://www.somedomain.com/link.html?pg= ... ct=2026855
where the link.html routine is doing a GET on the pg variable, the GET[pg] variable
is actually only http://www.americanprogressaction.org/s ... =klLWJcP7H
There's also a GET variable that is 1331575
and a GET[ct] that is 2026855
You can't just redirect to GET[pg]
You have to reassemble all the GET variables (using foreach)
and then redirect.
Simple when you see it!
....Vidya
- nickman013
- Forum Regular
- Posts: 764
- Joined: Sun Aug 14, 2005 12:02 am
- Location: Long Island, New York