CakePHP : How To Get Current URL In View In CakePHPPosted by in CakePHP
Hello Friends, Sometimes we want take current URL in cakePHP in view, Today I got current URL for transferring to that URL after log in. I have tried so many things to work it out and finally I got one working way to get current URL in view. We can use $_SERVER variable to get current URL but cakePHP giving its own method to get current URL in view file. It is very easy and it is working perfectly I have used it in my web application and it is working smoothly.
So if you want to take current URL in cakePHP view than check out below code :
echo Router::url($this->here, true);
This will output current URL. If you want relative path and not full URL than you can do like this :
By this you can get relative path in the view.