Heim >Backend-Entwicklung >PHP-Tutorial >yii要配置出这样一个url,需要怎么定义路由规则?

yii要配置出这样一个url,需要怎么定义路由规则?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 20:42:52970Durchsuche

我现在想要配置出这样一个url,需要怎么定义路由规则?
news/<alias>/list-<page>.html</page></alias>
<alias></alias>代表唯一的分类别名。
<page></page>代表分页的页码。
现在做了这样的配置:

'rules'=>array(
    'index'=>'site/index',
    'all' =>'house/base/index',
    'news/<alias:>/index'=>'news/list',
    'news/list/<alias:>-<page:>'=>'news/list',
    #'news/<alias:>/page/<page:>'=>'news/list',
    #'<controller:>/<action:>/<id:>'=>'<controller>/<action>',
    #'<controller:>/<action:>'=>'>controller>/<action>',
),
</action></action:></controller:></action></controller></id:></action:></controller:></page:></alias:></page:></alias:></alias:>

回复内容:

我现在想要配置出这样一个url,需要怎么定义路由规则?
news/<alias>/list-<page>.html</page></alias>
<alias></alias>代表唯一的分类别名。
<page></page>代表分页的页码。
现在做了这样的配置:

'rules'=>array(
    'index'=>'site/index',
    'all' =>'house/base/index',
    'news/<alias:>/index'=>'news/list',
    'news/list/<alias:>-<page:>'=>'news/list',
    #'news/<alias:>/page/<page:>'=>'news/list',
    #'<controller:>/<action:>/<id:>'=>'<controller>/<action>',
    #'<controller:>/<action:>'=>'>controller>/<action>',
),
</action></action:></controller:></action></controller></id:></action:></controller:></page:></alias:></page:></alias:></alias:>

<code class="lang-php">'/news/<alias:>/list-<page:>'=>'/news/list'
</page:></alias:></code>
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn