zoukankan      html  css  js  c++  java
  • yii2 urlmanager的配置

    怎样把localhost/index.php?r=user变为localhost/user

    1.修改backend/config/main.php,在components数组中增加
      'urlManager' => [
        'enablePrettyUrl' => true,
        'showScriptName'=> false,
        'rules' => [
                    '<controller:w+>/<id:d+>' => '<controller>/view',
                    '<controller:w+>/<action:w+>/<id:d+>' => '<controller>/<action>',
                    '<controller:w+>/<action:w+>' => '<controller>/<action>',
                    ['class' => 'yii estUrlRule', 'controller' => ['user', 'news']],
            ],

        ],
    2.在backend/web/下增加.htaccess
      RewriteEngine on
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . index.php

  • 相关阅读:
    Counting Stars hdu
    Color it hdu
    steins;Gate
    原根
    3-idiots
    Tree
    洛谷P1352 没有上司的舞会
    洛谷P1131 时态同步
    洛谷P3177 树上染色
    Codeforces Round #617 (Div. 3)
  • 原文地址:https://www.cnblogs.com/yangbanban/p/4538597.html
Copyright © 2011-2022 走看看