2016-01-11 62 views
0

我已完成並將我的yii2項目(高級模板)上載到託管(在nginx 1.4.4上運行)。現在,當我想登錄到管理後端並輸入登錄名/密碼時,它會啓動無限重定向循環。在我的本地服務器中,它不表現如此。yii2高級模板:登錄導致inifinite重定向循環

我在網上衝浪,但找不到任何答案。希望有人遇到這種情況,並能夠弄清楚,問題是什麼。

一些細節:

服務器:nginx 1.4.4; X緩存:是 清漆也啓用。

如有必要,我可以提供更多信息。

回答

1

你應該把應用分成兩部分。分開保持前端會話和後端會話。並閱讀本指南。推薦Nginx的配置 http://www.yiiframework.com/doc-2.0/guide-start-installation.html

server { 
 
    charset utf-8; 
 
    client_max_body_size 128M; 
 

 
    listen 80; ## listen for ipv4 
 
    #listen [::]:80 default_server ipv6only=on; ## listen for ipv6 
 

 
    server_name mysite.local; 
 
    root  /path/to/basic/web; 
 
    index  index.php; 
 

 
    access_log /path/to/basic/log/access.log; 
 
    error_log /path/to/basic/log/error.log; 
 

 
    location/{ 
 
     # Redirect everything that isn't a real file to index.php 
 
     try_files $uri $uri/ /index.php?$args; 
 
    } 
 

 
    # uncomment to avoid processing of calls to non-existing static files by Yii 
 
    #location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ { 
 
    # try_files $uri =404; 
 
    #} 
 
    #error_page 404 /404.html; 
 

 
    location ~ \.php$ { 
 
     include fastcgi_params; 
 
     fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; 
 
     fastcgi_pass 127.0.0.1:9000; 
 
     #fastcgi_pass unix:/var/run/php5-fpm.sock; 
 
     try_files $uri =404; 
 
    } 
 

 
    location ~ /\.(ht|svn|git) { 
 
     deny all; 
 
    } 
 
}