2014-02-21 25 views
2

我有以下URL模式時重複Django的網址中使用runfcgi

<a class='nav-link' href='{% url 'contact' %}'>Contact</a> 

的URL獲取的頁面呈現爲http://localhost:8000/contact/ 。一切工作正常,當使用./manage.py runserver進行測試時...

...但後來我運行./manage.py runfcgi - 然後當我導航到聯繫頁面時,導航中的URL指向http://localhost:8000/contact/contact/!我曾嘗試在開始時加入斜線以使網址絕對,但網址似乎絕對沒有。

我使用nginx的作爲前端,以及相關的配置從有:

location/{ 
    include fastcgi_params; 
    fastcgi_pass unix:/tmp/django.sock; 
    fastcgi_param PATH_INFO $fastcgi_script_name; 
    fastcgi_pass_header Authorization; 
    fastcgi_intercept_errors off; 
} 

我使用Django 1.6 &的Python 2.7.4。任何人有任何見解?

回答

0

8個月後,我發現在另一個我的網站上發生了這種情況,因爲SCRIPT_NAMEinclude fastcgi_params之前被設置!

最後的工作配置片斷:

location/{ 
    include fastcgi_params; 
    fastcgi_param SCRIPT_NAME ""; 
    fastcgi_pass unix:/tmp/django.sock; 
    fastcgi_param PATH_INFO $fastcgi_script_name; 
    fastcgi_pass_header Authorization; 
    fastcgi_intercept_errors off; 
}