I want to create a link on my error page to take user back to the previous link. Suppose the current URL is http://example.com/site/product, and a user try to view http://example.com/site/product?id=100 and a product with id =100 does not exit, the system should throw 404 error to the error page, now if i want to create a link to take the user back to http://example.com/site/product the previous URl how do I make this work. i can make this work by hardcoding this in my error views file, but i want it dynamically as i have many controller an action using the same view file.
I try this in my site conteoller
controller/site public function actions() { $url = Url::remember(); return [ 'error' => [ 'class' => 'yii\web\ErrorAction', ], $this->render('error',['url'=>$url]), ]; }
and try to get the value the in error view file like this
/views/site/error.php <p> <?= Html::a('go back', [$url)?> </p>
but it has no vaule.. please any good idea on how to make this work, am also open to new solution