Home>Article>php教程> yii2.0 UrlManage link url rule analysis

yii2.0 UrlManage link url rule analysis

黄舟
黄舟 Original
2017-01-03 09:25:11 1690browse


Url rules:

urlmanager is configured as an application component in [[yii aseApplication]]. You can access the instance through Yii: Yii::$app->urlManager

You can add an array to "components" under your application configuration, the example is as follows:

'urlManager' => [ 'enablePrettyUrl' => true, 'rules' => [ // your rules go here ], // ... ]

rules rule example:

[ 'dashboard' => 'site/index', 'POST s' => '/create', 's' => '/index', 'PUT /' => '/update', 'DELETE /' => '/delete', '/' => '/view', ]; rules' => [ // 为路由指定了一个别名,以 post 的复数形式来表示 post/index 路由 'posts' => 'post/index', // id 是命名参数,post/100 形式的URL,其实是 post/view&id=100 'post/' => 'post/view', // controller action 和 id 以命名参数形式出现 '//'=> '/', // 包含了 HTTP 方法限定,仅限于DELETE方法 'DELETE /' => '/delete', // 需要将 Web Server 配置成可以接收 *.digpage.com 域名的请求 'http://.digpage.com//profile' => 'user/profile',]

The above is the content of yii2.0 UrlManage link url rule analysis. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!


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