As a developer we might need to get current url in cakephp to show it or use it on view page or to store it to some variable for reference, we can use CakePHP internal function to retrieve current URL or relative path. I always wanted to use some inbuilt solution rather than using traditional PHP code i.e. $_SERVER, after several minutes of efforts, I found this code.
echo Router::url($this->here, true);
This will give us full URL with hostname.
If you want to get relative path instead of full URL, use the following code:
This will produce absolute URL excluding hostname i.e. /controller/abc/xyz/
For more information, visit http://www.cakedc.com/