2017-07-12 114 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

就是這樣。 謝謝