日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Yii 2.0 GII 访问404错误

發布時間:2025/3/15 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Yii 2.0 GII 访问404错误 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

網上大部分都是普通的開啟和配置資料?
按照網上資料配置 訪問localhost/index/php?r=gii 總是提示404錯誤?

解決方法如下:?
Yii基礎版中的 web.php 代碼如下

if (YII_ENV_DEV) {// configuration adjustments for 'dev' environment$config['bootstrap'][] = 'debug';$config['modules']['debug'] = ['class' => 'yii\debug\Module',// uncomment the following to add your IP if you are not connecting from localhost.//'allowedIPs' => ['127.0.0.1', '::1'], ];$config['bootstrap'][] = 'gii';$config['modules']['gii'] = ['class' => 'yii\gii\Module',// uncomment the following to add your IP if you are not connecting from localhost.'allowedIPs' => ['127.0.0.1', '::1'],]; }

注意這里的變量是YII_ENV_DEV 而在入口文件index.php中配置的是

defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV','dev'); //需要根絕web.php中的變量YII_ENV_DEV增加對應的開啟設置 defined('YII_ENV_DEV ') or define('YII_ENV_DEV ', true);require(__DIR__ . '/../vendor/autoload.php'); require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');$config = require(__DIR__ . '/../config/web.php');(new yii\web\Application($config))->run();

?

2.路由配置?
enablePrettyUrl 設置為false

//路由配置'urlManager' => ['enablePrettyUrl' => false,//路由的路徑化 去掉 ?r='showScriptName' => false,//隱藏入口Index.php文件//'suffix' => '.html',//假后綴(fake suffix) .html'rules' => ['<controller:\w+>/<name:\w+>/<action:\w+>'=>'<controller>/<action>','company/<id:\d+>.html'=>'company/list',],],

?

3.GII是基于本地訪問使用的 所有使用localhost或127.0.0.1來訪問。

轉載于:https://www.cnblogs.com/liangzia/p/10882783.html

總結

以上是生活随笔為你收集整理的Yii 2.0 GII 访问404错误的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。