I've tried doing the following in my 404 error page to create a back link the referring page so that I don't have to rely on javascript.
<?php $this->set('refer', $this->referer()); ?>
<p><?php echo '<a href="'.$refer.'">Back to previous page</a>'; ?></p>
However it doesn't work... Any ideas why? This code is done in /Errors/error404.ctp
Use the request object :)
$this->request->referer();
In CakePHP3 you can use:
<li><?= $this->Html->link(__('Back'), $this->request->referer()) ?></li>
It should be fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With