tsurantino
tsurantino

Reputation: 1027

Django defaulting to HTTPS

I have a working django install with django-sslify and it correctly HTTPS my urls but with inconsistent behaviour.

For example, if I type socialspark.spuro.org it takes me to an HTTP page. If I type socialspark.spuro.org/something it takes me to an HTTPS page.

Of course, if I type https://socialspark.spuro.org/ it will take me to an HTTPS page.

It's concerning for me that with one misspelling, all my HTTPS support will be gone. What should I do to remedy this issue?

Upvotes: 2

Views: 942

Answers (1)

gitaarik
gitaarik

Reputation: 46300

Take a look at django-secure, it's got middleware that can do this for you. After you installed it you can put this in your settings.py:

SECURE_SSL_REDIRECT = True

However if you have the access, you could also do this in the webserver (Nginx, Apache). That will be much faster.

Upvotes: 2

Related Questions