HTTPS redirect with Django wsgi.py

Glen Tomkowiak
1 min readNov 8, 2019

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

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