2017-08-07 51 views
0

我克隆了我們的存儲庫,並創建了像我自己的項目一樣的URL規則。現在,我已經將登錄後得到這樣的錯誤:URL管理器不會路由

Firefox: 
Fehler: Umleitungsfehler 
The website called is rerouting request,which never will come to an end. 
This problem sometimes occures, if cookies are deactivated 

Chrome: 
ERR_TOO_MANY_REDIRECTS 

我definetly接受了這兩個瀏覽器使用cookie! 調試顯示我,我已經打了302個請求,所以Yii崩潰了! 我使用Windows,而不是LINUX,所以我不在乎任何權限。 下面是規則:

'urlManager' => [ 
 
       'class' => 'yii\web\UrlManager', 
 
       'enablePrettyUrl' => true, 
 
       'showScriptName' => true, 
 
       'enableStrictParsing' => true, 
 
       'rules' => [ 
 
        '/' => 'site/login', 
 
        'home' => 'site/index', 
 
        'logout' => 'site/logout', 
 
        'contact' => 'site/contact', 
 
        'signup' => 'site/signup', 
 
        'reset' => 'site/request-password-reset', 
 
        '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>', 
 
        '<action:(contact|captcha)>' => 'site/<action>' 
 
       ],

這裏是前端配置:

<?php 
 

 
$config = [ 
 
    // LZA 17-07-30 
 
    'sourceLanguage' => 'de-DE', 
 
    'language' => 'de-DE', 
 
    // LZA 17-07-30 siehe Funktionen in http://demos.krajee.com/grid#module  
 
    'components' => [ 
 
     'request' => [ 
 
      // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation 
 
      'cookieValidationKey' => '4lD2RxDNkC4ckpwxTmkDzOLIvk0JMs3F', 
 
     ], 
 
    ], 
 
]; 
 

 
if (!YII_ENV_TEST) { 
 
    // configuration adjustments for 'dev' environment 
 
    $config['bootstrap'][] = 'debug'; 
 
    $config['modules']['debug'] = [ 
 
     'class' => 'yii\debug\Module', 
 
    ]; 
 

 
    $config['bootstrap'][] = 'gii'; 
 
    $config['modules']['gii'] = [ 
 
     'class' => 'yii\gii\Module', 
 
     // LZA 17-07-30 CRUD 
 
     'generators' => [// customized CRUD generator 
 
      'crud' => [ 
 
       // 'class' => 'app\myCrud\crud\Generator', // LZA 17-07-20 die Klasse von CRUD generator 
 
       'class' => '\common\wsl_dev\wsl_crud\crud\Generator', // LZA 17-07-20 die Klasse von CRUD generator 
 
       'templates' => [ 
 
        'myCrud' => '/@common/wsl_dev/wsl_crud/crud/default', //LZA 17-07-20 Templatename und Templatepfad 
 
       ] 
 
      ] 
 
     ], 
 
      // LZA 17-07-30 CRUD   
 
    ]; 
 
} 
 

 
return $config;

如果我deacitvate URLManger,設置

'enablePrettyUrl' => false, 

一切工作正常。 如果我把手動網址是這樣的:

http://localhost/yii2_perswitch/frontend/web/yiic.php/home 

一切正常,太

任何想法,如何解決這一問題? 我刪除了所有的cookies,沒有任何效果!

回答

0

解決方案1:

啓用從網絡/ index.php的調試模式(取消註釋兩行):

defined('YII_DEBUG') or define('YII_DEBUG', true); 
defined('YII_ENV') or define('YII_ENV', 'dev'); 

,你可以看到到底是什麼原因導致的問題。是

重定向次數過多錯誤,因爲 運行和資產文件夾中的777個權限並沒有設置。

解決方案2:

我認爲這個問題與cookie的路徑或域相關。我相信這個信息可能會有用。

https://github.com/samdark/yii2-cookbook/blob/master/book/cookies.md

+0

我使用Windows,所以我不需要任何權限。 Cookies在前端和後端都有定義(見上) – tklustig