dongxian2863 2013-11-16 08:49
浏览 115
已采纳

一个重定向脚本,用于执行上一页的完整URL路径

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.phpand redirect.phpwill 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!

  • 写回答

2条回答 默认 最新

  • dongxia19772008 2013-11-16 09:07
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型