yii2配置urlmanager無效

WBOY
發布: 2016-08-04 09:19:35
原創
1450 人瀏覽過

写了一个接口,使用路径为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>
登入後複製
登入後複製

真心求解,

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!