>  기사  >  백엔드 개발  >  Yii2 路由的问题

Yii2 路由的问题

WBOY
WBOY원래의
2016-06-06 20:14:07960검색

假设注册了一个名为article的Module,是不是以article开头的url(开启enablePrettyUrl,关闭showScriptName)都只能路由到article这个Module,不能是其他的Controller吗?

回复内容:

假设注册了一个名为article的Module,是不是以article开头的url(开启enablePrettyUrl,关闭showScriptName)都只能路由到article这个Module,不能是其他的Controller吗?

配置文件中urlmanager 属性rules中为你其他特别的要article打头的控制器配置规则,应该有效

看了一下api文档,当enablePrettyURL为true时可以自行配置。

A special shortcut format can be used if a rule only specifies pattern
and route: 'pattern' => 'route'. That is, instead of using a
configuration array, one can use the key to represent the pattern and
the value the corresponding route. For example, 'post/' =>
'post/view'.

这里的route应该可以自定义。

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.