Create your own url manager by subclassing CUrlManager
and ovveride createUrl
a bit, in example:
class MyUrlManager extends CUrlManager {
public function createUrl($route,$params=array(),$ampersand='&') {
if($route == 'proj/view' && isset($params['name'])) {
$params['name'] = processYourParamFunction($params['name']);
}
return parent::createUrl($route,$params,$ampersand);
}
}
Then modify your config to use this class:
...
'urlManager' => [
'class' => 'MyUrlManager'
...
]
It is one of great Yii features, natural inversion of control:)
For second part of question:
In you view action simply redirect to new url with createurl if you detect unwanted characters . Just make sure you not hit redirect loop.
Update:
To redirect with 301 just pass redirect code a third param to redirect call:
$this->redirect('route', true, 301);
Side note:
Use cannonical to point search engines to proper url