PHP Redirect - full URL's

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
DessieD32
Forum Newbie
Posts: 8
Joined: Wed Aug 16, 2006 5:04 am
Location: Dublin, sunny ole Ireland

PHP Redirect - full URL's

Post by DessieD32 »

Hi

I noticed someone in a previous post mentioned you should use full URLs when doing a header redirect.

Would anyone have any info on why full URL's should be used, and the possible problems with not using them? I'm having a problem with session's (only using IE tho, Firefox is fine) and am beginning to suspect it's down to this.

Any info at all v welcome.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Read the manual - http://uk.php.net/header
The manual wrote:Note: HTTP/1.1 requires an absolute URI as argument to Location: including the scheme, hostname and absolute path, but some clients accept relative URIs. You can usually use $_SERVER['HTTP_HOST'], $_SERVER['PHP_SELF'] and dirname() to make an absolute URI from a relative one yourself
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

HTTP standard is full URL for header redirection.
DessieD32
Forum Newbie
Posts: 8
Joined: Wed Aug 16, 2006 5:04 am
Location: Dublin, sunny ole Ireland

Post by DessieD32 »

Thanks for the REALLY fast responses.

My problem is around redirecting and losing SESSION info though I can see theres a lot of help out there on it which I'll start looking at.

What I find strange is the site works fine with Firefox, but not with IE. As the redirect etc is happening server side Im confuised why the browser I use would make any difference.

Cheers
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

DessieD32 wrote:As the redirect etc is happening server side...
That's just it, it isn't...the headers are sent to the client, then the client redirects you.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

We don't need to continue your other thread here, so let's keep both on topic please.
DessieD32
Forum Newbie
Posts: 8
Joined: Wed Aug 16, 2006 5:04 am
Location: Dublin, sunny ole Ireland

Post by DessieD32 »

Sorry, and thanks again - clears a lot up for me.
Post Reply