My solution for you is using PHP and Server capabilty to keep track of your PHP pages.
Use followong code in your markup and see the magic
<?php
url = htmlspecialchars($_SERVER[‘HTTP_REFERER’]);
echo "<a href='$url'>back</a>";
?>
——————————————————