To long of url to redirect

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

To long of url to redirect

Post by pinehead18 »

Ok, yesterday i wrote this script which worked fine for like 3 hours. It is this.


$_SESSION['go_to'] = $_SERVER["HTTP_REFERER"];
$go_to = $_SESSION['go_to'];
$url = explode("/", $go_to);
$lurl = "/".$url[3]."/".$url[4]."/".$url[5]."/".$url[6];

This gives the last url, if it does exist. For example if the person tries to login from the forums it give sthe address /forums/id_of forum/ and when the person logs in the header() sends it back to them.
header("location: ".$lurl."");

It works great if you are logging in from the forums, however if you are logging in from index.php then i get the following popup error from firefox.

"redirection limit for this url exceeded. unable to load the requested page, this may be caused by cookies that are blocked.

Thank you all

P.S at least i'm writing my own stuff now and having probs vs always asking how to write :)

- Anthony
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I've had this error, when I was accidently infinitely redirecting.. so you may want to look into where you are redirecting to.. to make sure it's not a self referencing one..
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

Post by pinehead18 »

So basically, if this re-direct was being re-directed towards a page that had another re-direct. That would be it, i am getting the error only ont he page that is doing the re-directing. So i should just put in a simple if statement
like if it = a certain page send here instead.

You've been a big help once again.

At least your not writing code for me like you used to :) Lets hope it stays that way.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I hope it stays that way too ;)
Post Reply