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('/') + '/');
});