Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cakePHP redirection with $this->referer() not working properly

Tags:

php

cakephp

I have one view file of TestController And on that I have added comment form (the url of page on which my page exist is www.example.com/test/view/slug)now comment form is posting on url www.example.com/comments/add action comment is adding successfully after addition I have written (in comment/add method)

            $this->redirect($this->referer());

what I was expecting is it should redirect to www.example.com/test/view/slug . its redirecting on that url on my localhost but when I deployed my application it is redirecting not redirecting propery it is redirecting on url www.example.com/comment/www.example.com and giving error

Error: The requested address '/comments/www.example.com' was not found on this server.
like image 851
Ganesh Patil Avatar asked Jan 18 '26 14:01

Ganesh Patil


1 Answers

Try this

$this->redirect( Router::url( $this->referer(), true ) );

This will use FULL urls in your redirect and this may fix your problem with adding your redirect to the current URL instead of just using it.

like image 140
Ilie Pandia Avatar answered Jan 20 '26 02:01

Ilie Pandia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!