>  기사  >  백엔드 개발  >  yii2配置urlmanager无效

yii2配置urlmanager无效

WBOY
WBOY원래의
2016-08-04 09:19:351443검색

写了一个接口,使用路径为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:>/<action:>'=>'<controller>/<action>',
            ],
        ],
</action></controller></action:></controller:></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:>/<action:>'=>'<controller>/<action>',
            ],
        ],
</action></controller></action:></controller:></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>

真心求解,

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