Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用php动态记住最后一个链接_Php_Ajax_Jquery_Http Referer - Fatal编程技术网

如何使用php动态记住最后一个链接

如何使用php动态记住最后一个链接,php,ajax,jquery,http-referer,Php,Ajax,Jquery,Http Referer,如何用php动态记住最后一个链接?例如,这是父页面的url http://website.com/#/events/upcoming-events/ 请注意,我在所有URL中都有一个哈希 这是子页面的 http://website.com/#/events/upcoming-events/event-1/ 在子页面上,我有一个返回到父页面的链接 <a href="<?php echo $_SERVER['HTTP_REFERER'];?>" class="button-b

如何用php动态记住最后一个链接?例如,这是父页面的url

http://website.com/#/events/upcoming-events/ 
请注意,我在所有URL中都有一个哈希

这是子页面的

http://website.com/#/events/upcoming-events/event-1/
在子页面上,我有一个返回到父页面的链接

<a href="<?php echo $_SERVER['HTTP_REFERER'];?>" class="button-back">Back</a>

$\u服务器['HTTP\u REFERER']只给我
http://website.com/ 当然可以。


那么我该如何解决这个问题呢?

在服务器端很难做到这一点,但您可以在客户端使用
jQuery

$(document).ready(function() {
    var hrefParts = location.href.split('/');
    hrefParts.splice(hrefParts.length - 2);
    $('.button-back').attr('href', hrefParts.join('/') + '/');
});

您无法在服务器端确定哈希URL,因为clinet不会在#符号之后发送任何内容。