HTTPS redirect with Django wsgi.py
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.