alankar1985
(Alankar Singh1985)
1
Hi
i have to show username in url like http://localhost:90/testyii/Alankar. where [color="#FF0000"]Alankar[/color] is username.
i user url rule ‘<firstname:\w+>’=>‘person/show’. rule is given below
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>array('<controller>/view','urlSuffix'=>'.jsp'),
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
'<firstname:\w+>'=>'person/show',
),
'showScriptName'=>false,
Now if i am entering url http://localhost:90/testyii/Alankar is working perfectly but i am using createUrl to generate a such url.
echo ‘<a href="’.Yii::app()->createUrl(’/person/show’,array(‘firstname’=>‘Abhishek’)).’" >Testing</a>’;
inspite of showing http://localhost:90/testyii/Alankar it shows http://localhost:90/testyii/person/show?firstname=Alankar
and what is the meaning of w,d,S in url rules
please help me to resolve this issue
thanks in advance
patrickm
(Yiiframework)
2
Have a look at this topic from the guide:
http://www.yiiframework.com/doc/guide/1.1/en/topics.url
You need to modify your config:
array(
......
'components'=>array(
......
'urlManager'=>array(
'urlFormat'=>'path',
),
),
);
Concerning the "meaning of w,d,S", have a look at some information about regular expressions.
alankar1985
(Alankar Singh1985)
3
Hi thanks for your reply
i did it but createUrl is not generation current seo friendly url
patrickm
(Yiiframework)
4
Mind posting your config so we can have a look at it?
alankar1985
(Alankar Singh1985)
5
config file is attached with it
alankar1985
(Alankar Singh1985)
6
Hi All 
After lot g
gling i found a simple solution. just put specific rules at the begining and then other general rules.
---------------------------Wrong Position---------------------------
‘rules’=>array(
‘<controller:\w+>/<id:\d+>’=>array(’<controller>/view’,‘urlSuffix’=>’.jsp’),
‘<controller:\w+>/<action:\w+>/<id:\d+>’=>’<controller>/<action>’,
‘<controller:\w+>/<action:\w+>’=>’<controller>/<action>’,
[color="#FF0000"]’<firstname:\w+>’=>‘person/show’[/color],
),
---------------------------Correct Position---------------------------
‘rules’=>array(
[color="#FF0000"]’<firstname:\w+>’=>‘person/show’,[/color]
‘<controller:\w+>/<id:\d+>’=>array(’<controller>/view’,‘urlSuffix’=>’.jsp’),
‘<controller:\w+>/<action:\w+>/<id:\d+>’=>’<controller>/<action>’,
‘<controller:\w+>/<action:\w+>’=>’<controller>/<action>’,
),
Hope this will help others 