Django redirect loop in form submit

Just to clarify, this is the first time I'm putting a django website to production.

I have a simple website in django that works locally. But when I deploy it in the production server it enters in redirect loop when I submit a form. Then the browser just tells me that a redirect loop occurred and asks to empty the cache and so on...

This problem happens in the admin. I don't know if it would happen in the frontend because it just doesn't have any form in the frontend.


  • I don't have any funky middlewares.
  • I tested in a virtual machine with more or less the same specs of the production server and it works fine.
  • The submitted data is correctly handled and saved
  • The rest of the website is fine

I'm using apache with wsgi in a shared host, through a .htaccess.

At this point I don't rule out the chance of a dns misconfiguration, but I already checked and looks fine.


AddHandler wsgi-script .wsgi
DirectoryIndex app22.wsgi

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteRule ^(.*)$ app22.wsgi/$1 [QSA,PT,L]


import os, sys

os.environ['DJANGO_SETTINGS_MODULE'] = 'BTT.settings'

path = '/home/bttmonch/apps'
if path not in sys.path:

path = '/home/bttmonch/apps/ENV/lib/python2.7/site-packages'
if path not in sys.path:

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

At this point I created a fresh new app with just the admin activated, to see if it was some codding issue and put it on the server. And the same thing happens.

I am using the same .htaccess and .wsgi files that I mentioned before.

My is just the basic:

from django.conf.urls.defaults import patterns, include, url

# Uncomment the next two lines to enable the admin:
from django.contrib import admin

urlpatterns = patterns('',
    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(,

I am accessing the app via I already tried accessing it through,, and


After poking around in the server I stopped getting a redirect loop. But now every time I save a form I get a 403 error. Than I clear the browser cookies and all comes back to normal, and the form data is successfully saved in the database.

At this point a just don't now what else to try...

Need Your Help

How to execute Symlink command in java

java command symlink

I am finding trouble in executing symlink command in java. My source filename and destination filename has space in it.

Rstudio-server environment variables not loading?

r hadoop cloudera rstudio rstudio-server

I'm trying to run rhadoop on Cloudera's hadoop distro (I can't remember if its CDH3 or 4), and am running into an issue: Rstudio server doesn't seem to recognize my global variables.