I was wondering if this is even possible... I am working on this flow
A user is on "ask-now" (http://domain.com/ask-now/
) page and click "ask" link, he will be redirected to "redirect.php
" and "redirect.php
" will redirect to answer.php
but the URL of answer.php
must carry the full url of http://domain.com/ask-now/
Like this form http://domain.com/answer.php/?ask=http://domain.com/ask-now/
and everytime user click "ask" on any webpage on my website they will always redirected to http://domain.com/answer.php/?ask=( THE FULL PATH URL WHERE THEY CAME FROM )
.
Can someone help me please? :)
FLOW UPDATE as Kumar requested. Thanks for the help buddy.
Detailed Version
I have a website http://domain.com/
. The website has lot of pages http://domain.com/page1/
--- http://domain.com/(and son on)
LOT! Each of the page has a anchor text "ASK" which is link to http://domain.com/redirect.php
and redirect.php
will redirect to http://domain.com/answer.php
.
What I want is the http://domain.com/answer.php
will carry the full path url of the previous page where the user came from. and show the url like this http://domain.com/answer.php/?ask=(THE FULL PATH WHERE THE USER CAME FROM)
.
Example: The user is from http://domain.com/page100/
and he click the link ask
which is redirected to answer.php
now, he is now on answer.php
page and he will see the full url above is http://domain.com/answer.php/?ask=http://domain.com/page100/
I think I have explained very well..
Thank you Kumar. Hope you can solve this!
in redirect.php add this logic
if($_SERVER["HTTP_REFERER"]=="http://domain.com/ask-now/"){
$location="http://domain.com/answer.php/?ask=".$_SERVER["HTTP_REFERER"];
header("Location: $location");
}
You can change your logic according to your requirement.
Simply save the current users' page to COOKIE or his SESSION, and get it later. I suggest this way because HTTP_REFERER is not always transmitted.
For example:
setcookie('ask_page', $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"], time() + 3600, /'); header("Location: /answer.php");
echo $_COOKIE['ask_page'];