CakePHP : How To Get Current URL In View 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 :
echo $this->here;
By this you can get relative path in the view.
Related Posts :
- CakePHP Session Timeout or Change Session Length in CakePHP
- jQuery 1.4.1 released After Release 12 Days of jQuery 1.4
- New WordPress Plugin – IGIT Related Posts With Thumb Image After Posts
- Remove index.php From URL By URL Rewriting Or htaccess Rule To Remove Index.php