复制代码 代码如下:
<?php echo CHtml::link('错误链接','user/register')?>
<?php echo CHtml::link('正确链接',array('user/register'))?>
复制代码 代码如下:
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:/w+>/<id:/d+>'=>'<controller>/view',
'<controller:/w+>/<action:/w+>/<id:/d+>'=>'<controller>/<action>',
'<controller:/w+>/<action:/w+>'=>'<controller>/<action>',
),
),
复制代码 代码如下:
/**
* Normalizes the input parameter to be a valid URL.
*
* If the input parameter is an empty string, the currently requested URL will be returned.
*
* If the input parameter is a non-empty string, it is treated as a valid URL and will
* be returned without any change.
*
* If the input parameter is an array, it is treated as a controller route and a list of
* GET parameters, and the {@link CController::createUrl} method will be invoked to
* create a URL. In this case, the first array element refers to the controller route,
* and the rest key-value pairs refer to the additional GET parameters for the URL.
* For example, <code>array('post/list', 'page'=>3)</code> may be used to generate the URL
* <code>/index.php?r=post/list&page=3</code>.
*
* @param mixed $url the parameter to be used to generate a valid URL
* @return string the normalized URL
*/
public static function normalizeUrl($url)
{
if(is_array($url))
{
if(isset($url[0]))
{
if(($c=Yii::app()->getController())!==null)
$url=$c->createUrl($url[0],array_splice($url,1));
else
$url=Yii::app()->createUrl($url[0],array_splice($url,1));
}
else
$url='';
}
return $url==='' ? Yii::app()->getRequest()->getUrl() : $url;
}
新闻热点
疑难解答