1

Is there a way to redirect or refresh page in PHP which will not lose the referrer?

For Example: Page1.php is being redirected to Page2.php So in this case, there is no referrer at all. I want to get referrer on Page2.php

And

A Visitor must be able to press BACK button in his/her browser to go back to Page1.php

*When I redirect from Page1.php to Page2.php then Google Analytics or other website Analytics solutions should be able to track the Referrer who referred Page2.php

I tried both of the below.

With This:

header( 'Location: http://www.yoursite.com/new_page.html' ) ;

And This:

header( "refresh:5;url=wherever.php" );

I really need a way out for this. Spent 7 hours straight to find the solution. But I'm unable to find.

Can somebody help me with this?

Thanks,

baburao113
  • 785
  • 2
  • 8
  • 12

3 Answers3

0

You could store the referrer URL in a session variable before sending the redirect header.

code_burgar
  • 12,025
  • 4
  • 35
  • 53
  • I couldn't do that and if I do that it's useless for me. Because when I redirect from Page1.php to Page2.php then Google Analytics or other website Analytics solutions should be able to track the Referrer who referred Page2.php – baburao113 Mar 08 '12 at 20:19
0

There has been a helpful discussion about 302 Redirects, Apache Configuration and possible work arounds at Will a 302 redirect maintain the referer string?

Community
  • 1
  • 1
sbstjn
  • 2,184
  • 1
  • 15
  • 13
  • Will it help me any way to accomplish this? ----> When I redirect from Page1.php to Page2.php then Google Analytics or other website Analytics solutions should be able to track the Referrer who referred Page2.php – baburao113 Mar 08 '12 at 20:30
-1

a 302 redirect response should preserve the referrer by convention - although this isn't specified anywhere as far as I know.

Hamish
  • 22,860
  • 8
  • 53
  • 67
  • Not sure what you are saying. I didn't get you. When I redirect from Page1.php to Page2.php then Google Analytics or other website Analytics solutions should be able to track the Referrer who referred Page2.php – baburao113 Mar 08 '12 at 20:24