Use any option below.
<?php echo $this->Html->url('/');?>
<?php Router::url('/', true); ?>
<?php echo $this->base;?>
<?php echo $this->webroot; ?>
Define the constant in Config / core.php as define("BASE_URL", "www.yoursite.com/"); and use BASE_URL anywhere in your project.
and create a common assistant with the following functions
<?php class CommonHelper extends AppHelper { function get_url($url){ return BASE_URL.$url; } function get_src($url){ echo BASE_URL.$url; } } ?>
and use anywhere in the project
$this->redirect($this->Common->get_url("login"); <a href="<?php $this->Common->get_src('users/login');?>">login</a>
Do not forget to include the general assistant in the controller
I recommend method 2 and 5 because they give the full url.
Subodh Ghulaxe Dec 01 2018-12-12T00: 00Z
source share