Simple question about GET parameters

I’m new to Yii and would like to define possible GET parameters in urlManager rules in the main.php config file and then access those parameters from within the Controller without worrying about sanitizing.

For example considering the following rule in main.php config:




'urlManager' => array(

	'urlFormat' => 'path',

	'showScriptName' => false,

	'rules' => array(

		'<action:myaction>/<year:\d{2}|\d{4}>' => 'site/<action>'

	)

)



Using the url "site/myaction?year=abc"




Yii::app()->request->getParam('year','default');



returns "abc" even though I would really expect "default" to be returned.

Using the url "site/myaction/2010", 2010 is returned, which is ok.

However how can I tell which case is used?

The latter case gives me the expected value, whereas the first case leaves me accepting any value. So I would need to sanitize in the Controller anyway.

What am I doing wrong?

Enable useStrictParsing in config, then only the rules you define in config are allowed.

Thanks! I should have said that I would prefer the GET parameter over making the information part of the url.

What’s the best practice to handle GET parameters in such a case? Check for valid GET params in the base Controller class?