Yii 2 enablePrettyUrl后不能访问gii

Yii 2 enablePrettyUrl后不能访问gii

 

本篇我们谈谈在enablePrettyUrl后不能访问gii的问题。关于gii 是什么,不在我们讨论的范围,这里只给出官网的一个链接

http://www.yiiframework.com/doc-2.0/guide-start-gii.html

Generating Code with Gii – Getting Started – The Definitive Guide to Yii …

为什么要使用enablePrettyUrl,在之前的博文中有提到

Yii 2.x 简化URL

如果是初始创建的Yii工程,直接使用

http://localhost/index.php?r=gii

就可以访问了,界面如下:

start-gii

但是当我们使用了简洁的url格式之后,访问的格式就不能是上面的URL了,而是

http://localhost/index.php/gii

但是如果我们还加了后缀之后

41         'urlManager' => [
 42             'enablePrettyUrl' => true,
 43             'showScriptName' => false,
 44             'suffix' => '.html',
 45             'enableStrictParsing' => false,
 46             'rules' => [
 47             ],
 48         ],

那么访问gii的url就又变了,

http://localhost/gii.html

如果不加html,那么就会得到404的错误。

Not Found (#404)

Page not found.

The above error occurred while the Web server was processing your request.

Please contact us if you think this is a server error. Thank you.

 

 

i

 

版权所有,禁止转载. 如需转载,请先征得博主的同意,并且表明文章转载自:IT夜班车,否则按侵权处理i.

    分享到:

Leave a Reply

Your email address will not be published. Required fields are marked *