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条)

报告相同问题?

悬赏问题

  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection
  • ¥15 nginx代理报502的错误
  • ¥100 当AWR1843发送完设置的固定帧后,如何使其再发送第一次的帧
  • ¥15 图示五个参数的模型校正是用什么方法做出来的。如何建立其他模型
  • ¥100 描述一下元器件的基本功能,pcba板的基本原理
  • ¥15 STM32无法向设备写入固件
  • ¥15 使用ESP8266连接阿里云出现问题
  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果