I am trying to extend cbaseurl class in YII with the following code:
public function parseUrl($manager,$request,$pathInfo,$rawPathInfo)
{
if (preg_match('%^(\w+)(/(\w+))?$%', $pathInfo, $matches))
{
$matches = explode('/', $pathInfo);
$count = strlen($matches[1]);
if ($matches[0] == 'qwin' && $count >10){
$matches[1] = str_replace( "_", " ", $matches[1]);
$sql = "SELECT ans, qwin_id FROM tbl_qwin WHERE ans = :answer";
$command = Yii::app()->db->createCommand($sql);
$command->bindValue('answer', $matches[1]);
$row = $command->queryRow();
return '/qwin/view/id/'.$row['qwin_id'];
}
}
return false; // this rule does not apply
}
So, for example if i request /qwin/silver_or_gold then i get Error 404 The requested page does not exist. But, the record exist with the same name without ‘_’ in my database. I don’t see where is the problem. Thanks in advance.