2014-01-24 23 views
0

我想將所有404錯誤頁面重定向到另一個站點example.com。我試圖寫這樣的東西:將404錯誤重定向到其他站點

handler404 = 'index.views.custom404' 
def custom404(request):  
    return HttpResponseRedirect(reverse('index')) 

但它不起作用。
我應該在這個操作的urls.py和views.py中寫什麼?

回答

0

只要寫的完全限定網址:

handler404 = 'index.views.custom404' 
def custom404(request):  
    return HttpResponseRedirect('http://othersite.com/custom404.html') 
+0

這是我的錯。我寫了'render_to_response'。現在它開始工作。在我設置'DEBUG = False'後,錯誤開始爲500.然後,我添加到settings.py'ALLOWED_HOSTS = ['*']'。所以現在一切工作。謝謝! – Cke4

相關問題