문제

how can I dynamically remember last link with php? For instance, this is the parent page's url,

http://website.com/#/events/upcoming-events/ 

note that I have a hash in all URLs.

and this is the child page's,

http://website.com/#/events/upcoming-events/event-1/

On the child page I have a link to go back to the parent page,

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

$_SERVER['HTTP_REFERER']; only gives me http://website.com/ of course.

How do I get around to this then?

도움이 되었습니까?

해결책

This will be difficult to do on server side but you can do this on client side using jQuery

$(document).ready(function() {
    var hrefParts = location.href.split('/');
    hrefParts.splice(hrefParts.length - 2);
    $('.button-back').attr('href', hrefParts.join('/') + '/');
});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top