HTTPS redirect with Django wsgi.py

Glen Tomkowiak
Nov 8 · 1 min read

Sometimes you have a tricky situation where you can deploy a Django application but have little control over the front end web server or load balancer terminating your SSL. The code snippet below is an easy way to issue a 301 redirect for any http request. It will also remove the www prefix.

Replace YOUR_DJANGO_SETTINGS.settings with your settings.

    Glen Tomkowiak

    Written by

    Things that interest me: cloud computing, cyber security, DevOps, and mobile / web development. Posts are my own.