HTTPS redirect with Django wsgi.py

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.

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

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