6

I am deploying a Django app on heroku and trying to force https on all pages. I use the following settings for that:

SECURE_SSL_REDIRECT = True
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

Now when I visit www.mysite.de it does in fact not redirect me to https. Any ideas what I am missing?

WeGi
  • 1,908
  • 1
  • 21
  • 33

1 Answers1

11

Try adding the following to your settings.py:

PREPEND_WWW = True
BASE_URL = "https://www.mysite.de"
ALLOWED_HOSTS = ['www.mysite.de', 'mysite.de']

Make sure you also have SecurityMiddleware and CommonMiddleware enabled.

YPCrumble
  • 26,610
  • 23
  • 107
  • 172