2017-07-12 113 views
0

我打开urlManager之前,写了规则的GII-发电机曾在访问发电机GII,Yii2

主机名/的index.php?R = GII

在那之后,我转身对urlManager主机名/ gii不起作用 也许是他写规则?但是如何? 选项

'GII'=> 'GII' 或 'GII'=> 'GII /指数',

不工作

'urlManager' => [ 
     'enablePrettyUrl' => true, 
     'showScriptName' => false, 
     'rules' => [ 
      '/' => 'site/index', 
      'about' => 'site/about', 
      'contact' => 'site/contact', 
      'login' => 'site/login', 
      'entry' => 'site/entry', 
      'gii' => 'gii', 
      'country/page/<page:\d+>' => 'country/index', 
     ], 
    ], 
+0

你开启可以参考[在URLManager中使用漂亮的URL](http://www.yiiframework.com/doc-2.0/guide-runtime-routing.html#using-pretty-urls)与[Web服务器配置](http://www.yiiframework.com/doc-2.0/guide-start-installation.html#recommended-apache-configuration)。 –

+1

更新您的问题并显示您的urlManager配置..请 – scaisEdge

回答

0

你要么删除gii条目和gii模块将可访问默认路由
或以某种方式指定它的完整规则

'gii/<controller:[a-z-]+>/<action:[a-z-]+>' => 'gii/<controller>/<action>' 

这里也有一个关于如何删除URL

0

看来你重写模块引起问题的/site参数nicer example

只需在您的应用程序目录的根目录创建一个名为.htaccess的文件并粘贴此代码即可。

SetEnv HTTP_MOD_REWRITE On 
RewriteEngine on 

# if a directory or a file exists, use it directly 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

# otherwise forward it to index.php 
RewriteRule . index.php 

,并删除了gii URL规则让你的URL规则是这样的:

'urlManager' => [ 
    'enablePrettyUrl' => true, 
    'showScriptName' => false, 
    'rules' => [ 
     '/' => 'site/index', 
     'about' => 'site/about', 
     'contact' => 'site/contact', 
     'login' => 'site/login', 
     'entry' => 'site/entry', 
     'country/page/<page:\d+>' => 'country/index', 
    ], 

],

现在这个样子访问gii

yourhost/your_app_dir/gii 

一个更它只在上工作为活动服务器,您需要允许访问ip address

就是这样。 谢谢