I have been through the documentation and tutuorials and many forum posts (unfortunately currently links posted in the forum are not working).
I am trying to rewrite my urls for entire directories…
I got static pages to rewrite by modifying the urlManager like this…
'login'=>'user/login',
which allows
www.site.com/user/login.php
to display as
www.site.com/login.php
The goal is to be able to take
user/
out of everything under the user directory.
In Using search engine and user friendly URLs it is mentioned to do
class ActiveRecord extends CActiveRecord
{
public function getUrl()
{
$controller=get_class($this);
$controller[0]=strtolower($controller[0]);
$params=array('id'=>$this->id);
// add the title parameter to the URL
if($this->hasAttribute('title'))
$params['title']=$this->title;
return Yii::app()->urlManager->createUrl($controller.'/view', $params);
}
}
// class Post extends ActiveRecord { ... }
Is this the approach that I should be taking rather than modifying the urlManager in the config file?