Jump to content


PHP and Redirect

  • Please log in to reply
4 replies to this topic

#1 mbabli

  • Members
  • PipPip
  • Member
  • 13 posts

Posted 21 August 2006 - 07:18 PM

Hello everyone,
  If I redirect HTML page using the <META EQUIV-HTTP="Refresh"...etc> What are my options of retreiving the source URL before the redirection. Any help would be appreciated.

PS:  $_SERVER['REFERRER'; Is an empty string after redirecting.

#2 pachelbel101

  • Members
  • PipPip
  • Member
  • 11 posts

Posted 21 August 2006 - 07:29 PM

Before the redirection you can use $_SERVER['PHP_SELF'] OR $_SERVER['REQUEST_URI'] to get the source URL.

Then you can carry it over to the next script by attaching it to the redirect url as a GET ("?src=$_SERVER[REQUEST_URI]") or store it in $_SESSION.

#3 ober

  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 21 August 2006 - 07:31 PM

I think you want $_SERVER['HTTP_REFERER'].

Info: PHP Manual

#4 mbabli

  • Members
  • PipPip
  • Member
  • 13 posts

Posted 21 August 2006 - 07:35 PM

Thanks for the fast reply (Both):

  For solution 1: Unfortunately, the source page is HTML (Static), however, what I need is the source url (the info I need is in it). and
  altering Apache to hanle html as php is not the most feasible at the moment.

  For Solution 2: HTTP_REFERRER is an empty string if redirected because the referrer would be the browser itself.

  Any more suggestions? Thanks in advance

#5 theblain

  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 21 August 2006 - 09:06 PM

You can't use $_SERVER['HTTP_REFERRER'] BEFORE you redirect, and then pass the variable to the redirected page?

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users