Comparing
#2 with
#3
Revision #3 was created by marcovtwout on Dec 12, 2011, 3:20:26 PM.
updated code samples from fix in comments by redguy
« Previous (#2) Next (#4) »
Content
[...]
```php
public function beforeAction($action)
{
if (Yii::app()->request->$ url
!=
CHtml::normalizeUrl(array_merge(
array(
"/" . $this->route
), $_GET
)))
$this->redirect(CHtml::normalizeUrl(array_merge(array($this->route), $_GET)) );
if( Yii::app()->request->url != CHtml::normalizeUrl( $url ) ) {
$this->redirect( $url , true, 301
);
}
return parent::beforeAction($action);
}
``` [...]
public function beforeAction($action)
{
if (Yii::app()->request->$ url
!=
CHtml::normalizeUrl(array_merge(
array(
"/" . $this->route
), $_GET
))) );
$this->redirect(CHtml::normalizeUrl(array_merge(array($this->route), $_GET))if( Yii::app()->request->url != CHtml::normalizeUrl( $url ) ) {
$this->redirect( $url , true, 301
);
}
return parent::beforeAction($action);
}
}
```
Notice that you cannot add this rule for actionError and actionIndex, so if you want to make unique addresses in the site controller you cannot extend the master controller, but you have to implement a special method with exception for this two actions.
Links [...]