how to use CHtml::link() generate a absolute url?

i use CHtml::link() generate a link for mail,but it’s a relative url,in mail it’s like /index.php?r=test/test&id=1

but i need

can CHtml::link() generate a absolute url?’.CHtml::link()


Try this:

echo CHtml::link('read more', $this->createAbsoluteUrl('test/test',array('id'=>$id)));

I had the same issue, so I used a base tag and then set relative urls.


<?php echo '<base href="'.$this->createAbsoluteUrl('/').'/" />'; ?>



<?php echo CHtml::link('Contact Us', 'site/contact');?>

<?php echo CHtml::link(‘Link Text’,array(‘controller/action’,

                                     'param1'=&gt;'value1')); ?&gt;


CHtml::link(‘Home’, $this->createAbsoluteUrl(’/’));

Also you can use CController


CHtml::link('Home', CController::CreateUrl('//gallery/mail?action=index'));