It like ask what is better miles or pounds?
. That functions are very different.
You need to use redirect
when need to change page without user action in some conditions, for example in controller:
if($money==0)
{
$this->redirect(array('alerts/notEnoughMoney'));
}
If you want to generate address what will used for example in html links, then you need to use createUrl
, because it will:
- Avoid unnecessary step with redirect
- Better for SEO, and will be more user friendly
- Better for customizing
You can use createUrl
in view, for example:
<?php
$link = $this->createUrl(array('user/profile'));
?>
<a href="<?php echo $link ?>">My Profile</a>
In any case, if you using redirects what visible for search bots you need to add second parameter:
$this->redirect(array('alerts/notEnoughMoney'),301);
----------------------------------------------^^^^
With this parameter bot will understand what this next page is permanent and will cache it as "main".