URL manager rules problem

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?

Will be good to see your rules.

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.

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',

           ),

 

From your rules:




'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+>.

Thank you very much I think I got it. I just need to help yii to recognize that each rule is different.