url manager

Hi, i’m new at yii and love to code with yii.

i want to ask how to create rules for below example :

url-example : http:www.abc.com/aloha123

i want to get aloha123 as parameter value and put the request in specified one default controller and action.

currently the config for url manager as below.

            'urlManager'=>array(


		'urlFormat'=>'path',


		'showScriptName'=>false,


		'rules'=>array(


			'<controller:\w+>/<id:\d+>'=>'<controller>/view',


			'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',


			'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',


		),


	),

thank you :)

where is the bug?

http://www.yiiframework.com/doc/guide/1.1/en/topics.url

Sorry this post suppose not in Bug Discussion.

NOTE: moved to proper section (General Discussion instead of Bug Discussion)

and deleted the one you just opened in the general section… please do not post same questions more than once

You need to describe what you want to get, to witch controller and action pass aloha123 ?

what to do with it? treat it as a get parametr?

hi dckurushin,

for example :

url: www.abc.com/aloha123

i want to put this request directly to

controller -> default Controller

action -> test (actionTes)

class DefaultController extends Controller

{

    public  function actionTes($value)


{


	 //do something with $values;


	 //$value --> [b]aloha123[/b]


}

}

currently for accessing that controller the url as :

www.abc.com/index.php/default/tes/value/aloha123

so how can i configure the urlmanager config? so the url became this : www.abc.com/aloha123

thank you

any update… faced same issue…

thx

Make sure to read the link in reply #2 to see how the following works. Using the configuration in the opening post, you can the update the main config file like this:




'urlManager'=>array(

    'urlFormat'=>'path',

    'showScriptName'=>false,

    'rules'=>array(

        '<value:\w+>' => 'default/test',   // <--- Add this line.

        '<controller:\w+>/<id:\d+>'=>'<controller>/view',

        '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

        '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

    ),

),



The controller would look like this:




<?php

// protected/controllers/DefaultController.php

class DefaultController extends Controller

{


    public function actionTest($value)

    {

        echo 'The passed value is ' . $value;

    }


}

?>



Note that the \w+ in the value part is a regular expression. Specifically, it tells us that the value must consist of one or more word characters (a-z, A-Z, 0-9 or underscore).