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

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

WBOY
WBOYOriginal
2016-06-06 20:42:52920browse

我现在想要配置出这样一个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>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn