UrlManager question

In my urlmanager I got:




'albums/photo/<photo_id:\d+>/<album_id:\d+>'=>'user/albums/photo',



This works fine, but now I want to do something similar where the first parameter is an activationkey and the second an email adress.

I came up with this but it doesn’t seem to work:




'activation/<activkey:\w+>/<email:\w+>'=>'user/activation',



The only reason I can think of why this doesn’t work is that the activation key is made up from letters and numbers, but not entirly sure how to write that in the urlmanager. I read this about URL’s but most examples are with digits, or just plain strings, not a mixture of them.

What I get now if I enter a hyperlink like:




http://landingpage.local/activation/4200b5777d66da97ad0c86013077db48/email%40test.nl



I get an error that says: "Unable to resolve the request".

entire urlmanager:




'urlManager'=>array(

	'urlFormat'=>'path',

	'showScriptName'=>false,

	'rules'=>array(

		''=>'user/login',

		'home'=>'user/home/index',

		'register'=>'user/home/register',

		'logout'=>'user/home/logout',

		'music/requestsong'=>'user/music/requestsong',

		'music'=>'user/music/index',

		'taxi'=>'landingpage/taxi/index',

		'friends'=>'user/friends/index',

		'albums'=>'user/albums/index',

		'albums/<album_id:\d+>'=>'user/albums/photos',

		'albums/photo/<photo_id:\d+>/<album_id:\d+>'=>'user/albums/photo',

		'news'=>'user/news',

		'news/archive'=>'user/news/archive',

		'registerparty/<party_id:\d+>/<user_id:\d+>'=>'user/home/registerforparty',

		'activation/<activkey:\w+>/<email:\w+>'=>'user/activation',

	),

),



Haven’t tested but this should work




'activation/<activkey:>/<email:\w+>'=>'user/activation',

From the Definitive guide to Yii:

<ParamName:ParamPattern>

where ParamName specifies the name of a GET parameter, and the optionalParamPattern specifies the regular expression that should be used tomatch the value of the GET parameter. In case when ParamPattern is omitted,it means the parameter should match any characters except the slash /.

use \w\d+

You need to explore Regular Expressions:

try to test:




var_dump(preg_match('/\w+/', 'email@test.nl')); // <email:\w+>

but pattern


[^@]+@\w+\.\w+

(


<email:[^@]+@\w+\.\w+>

) will help you

Thanks, problem solved

‘activation/<activkey:>/<email:>’ did the trick.

Yea and it will accept any parameters. You should use some rules to limit the parameters it allows.