I've got many rules on my url manager and sometimes the proper page to be displayed does not show. Then if I rearrange the rules and assign it as the first rule it works out perfectly then another rule does not work. What could be affecting this?
Page 1 of 1
URL manager rules problem
#2
Posted 02 June 2010 - 12:14 PM
Will be good to see your rules.
The order of url rules is important sometimes. Just for example:
The second rule will never work.
The order of url rules is important sometimes. Just for example:
'foo/<bar:.*>'=>'controller/action1', 'foo/<bar:\d+>'=>'controller/action2',
The second rule will never work.
#3
Posted 02 June 2010 - 12:21 PM
I see, that must be the problem. My arrangement is really messed up. I just added rules everywhere. Could you give me some tips on how to properly place the rules. Thanks for the help.
'rules'=>array(
'ads/post'=>'bsAds/newitem',
'ads/<type>/<prop>/<city>/<loc>'=>'bsAds/list',
'ads/<type>/<prop>/<city>'=>'bsAds/list',
'ads/<type>/<prop>'=>'bsAds/list',
'ads/<type>'=>'bsAds/list',
'user/step1'=>'userInfo/step1',
'user/step2'=>'userInfo/step2',
'user/step3'=>'userInfo/step3',
'<type>/<user>'=>'userInfo/show',
'u/<user>'=>'userInfo/show',
'ads/<cat>/property/<prop>'=>'bsAds/list',
'ads/<cat>/make/<make>'=>'bsAds/list',
'ads/<cat>/location/<loc>'=>'bsAds/list',
'<id>/<pagetitle>' => 'bsOtherpages/show',
'partners'=>'bsPartners/list',
'partners/apply'=>'bsPartners/create',
'logout'=>'site/logout',
'alerts'=>'bsAlerts/create',
'bookmarks'=>'userBookmark/list',
'login'=>'site/login',
'forum'=>'forumInfo/list',
'forum/<name>'=>'forumTopic/list',
'forum/<name>/post'=>'forumTopic/create',
'forum/view/<topicid>'=>'forumPost/list',
'forum/<topicid>/reply'=>'forumPost/create',
'groups'=>'userGroup/list',
'ads/tags/<tag>'=>'bsAds/list',
'ads/date/<date>'=>'bsAds/list',
'ads'=>'bsAds/list',
'search/<term>'=>'bsAds/search',
'<cat>'=>'bsAds/list',
'ads/<id>/<type>/<prop>/<city>/<loc>/<title>'=>'bsAds/show',
'ads/<id>/<make>/<model>/<type>/<title>'=>'bsAds/show',
'ads/<id>/<loc>/<prop>/<type>/<title>'=>'bsAds/show',
'ads/<id>/<make>/<type>/<model>/<title>'=>'bsAds/show',
'auto/<id>/<make>/<model>/<type>/<title>'=>'auto/show',
'mobile/<id>/<type>/<title>'=>'mobile/show',
'realty/<id>/<type>/<title>'=>'realty/show',
),
#4
Posted 02 June 2010 - 12:33 PM
From your rules:
How will Yii guess which rule to choose, if it will be "ads/15/abc/def/ghi/jkl" ? You should specify the range for params. For example, <make> can be only "foo" or "bar". Or maybe it should be a number: <loc:\d+>.
'ads/<id>/<make>/<model>/<type>/<title>'=>'bsAds/show', 'ads/<id>/<loc>/<prop>/<type>/<title>'=>'bsAds/show',
How will Yii guess which rule to choose, if it will be "ads/15/abc/def/ghi/jkl" ? You should specify the range for params. For example, <make> can be only "foo" or "bar". Or maybe it should be a number: <loc:\d+>.
#5
Posted 02 June 2010 - 01:32 PM
Thank you very much I think I got it. I just need to help yii to recognize that each rule is different.
Share this topic:
Page 1 of 1

Help












