- Author:
- careercoder
- Posted:
- May 24, 2014
- Language:
- Python
- Version:
- 1.5
- Score:
- 0 (after 0 ratings)
A simple way to force SSL on all pages. It's very simple at this point - the only issue I can see right now and I will address this later is if someone sends http:// in another portion of your url.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #########
# Not Currently Working, it was... something happened fixing
#########
__license__ = "Python"
__copyright__ = "Copyright (C) 2014 Jody Fitzpatrick"
__author__ = "Jody Fitzpatrick - [email protected]"
from django.http import HttpResponseRedirect, HttpResponsePermanentRedirect
class SSLRedirect:
def process_request(self, request):
if request.META['HTTP_HOST'] == 'http':
newurl = str(request.build_absolute_uri()).replace('http://', 'https://')
return HttpResponsePermanentRedirect(newurl)
|
More like this
- Template tag - list punctuation for a list of items by shapiromatron 11 months, 2 weeks ago
- JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 11 months, 3 weeks ago
- Serializer factory with Django Rest Framework by julio 1 year, 6 months ago
- Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 7 months ago
- Help text hyperlinks by sa2812 1 year, 8 months ago
Comments
Please login first before commenting.