Home  >  Article  >  Backend Development  >  yii2 configuration urlmanager is invalid

yii2 configuration urlmanager is invalid

WBOY
WBOYOriginal
2016-08-04 09:19:351444browse

写了一个接口,使用路径为localhost/api/web/index.php?r=user/test
actiontest的代码就是echo '123';
根据网上的教程,配置了urlmanager,代码如下

<code>'urlManager' => [
            'enablePrettyUrl' => true,  //美化url==ture
            'enableStrictParsing' => false,  //不启用严格解析 
            'showScriptName' => false,   //隐藏index.php
            'rules' => [
                '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
            ],
        ],
</code>

然后配置了nginx的rewrite

listen 80;

<code>server_name  localhost;

location / {
    root   D:/Github/Server/advanced;
    index  index.php index.html index.htm;
    #开启rewirte
    if (!-e $request_filename){
        rewrite ^/(.*) /index.php?r=$1 last;
    }        </code>

真心求解,

回复内容:

写了一个接口,使用路径为localhost/api/web/index.php?r=user/test
actiontest的代码就是echo '123';
根据网上的教程,配置了urlmanager,代码如下

<code>'urlManager' => [
            'enablePrettyUrl' => true,  //美化url==ture
            'enableStrictParsing' => false,  //不启用严格解析 
            'showScriptName' => false,   //隐藏index.php
            'rules' => [
                '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
            ],
        ],
</code>

然后配置了nginx的rewrite

listen 80;

<code>server_name  localhost;

location / {
    root   D:/Github/Server/advanced;
    index  index.php index.html index.htm;
    #开启rewirte
    if (!-e $request_filename){
        rewrite ^/(.*) /index.php?r=$1 last;
    }        </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
Previous article:php. virtual host failedNext article:php. virtual host failed