Reputation: 57176
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?
Upvotes: 0
Views: 168
Reputation: 6612
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('/') + '/');
});
Upvotes: 1