login community faq

Currently, I'am serving my django website with http . But for some urls I want to use https. How to do it?

asked Sep 07 '12 at 23:58

anandkr's gravatar image

anandkr
32

edited Sep 07 '12 at 23:59


First, you will need to make sure that your application is available over both http and https. This is described here.

Once the application can be accessed under both protocols, you then can redirect different pages to different protocols as needed. This is shown here.

Hope that helps!

answered Sep 08 '12 at 00:09

ryans's gravatar image

ryans ♦♦
28411420

Ok! for the 2nd config. for e.g. if I want to redirect urls starting with http://example.com/secure/ to https then in httpd.conf, I would use:

RewriteEngine On

RewriteCond %{REQUEST_URI} ^secure//*

RewriteCond %{HTTP:X-Forwarded-SSL} !on

RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

(Sep 08 '12 at 01:24) anandkr anandkr's gravatar image

I believe you mean: ^secure/.* but yes; precisely.

(Sep 08 '12 at 01:35) ryans ♦♦ ryans's gravatar image

I suppose ^secure/.* will match strings like /secure.something whereas, I want to lay my secure urls under /secure/ as:

https://example.com/secure/voting

https://example.com/secure/transcation

so what reg. expr.?

(Sep 08 '12 at 01:44) anandkr anandkr's gravatar image

The / in the regular expression means that a slash is required, so /secure.something won't match ^secure/.*.

If it's not working, try escaping the slash (^secure\/.*), although I think that in this particular context it's not actually necessary.

(Sep 08 '12 at 01:59) ryans ♦♦ ryans's gravatar image

oh! I got confused between forward(/) & backslash(\). How Silly!

One more thing, in the webfaction cp, for https I've created a website record for my application but only mapped it on /secure path. I hope its ok!

(Sep 08 '12 at 02:10) anandkr anandkr's gravatar image

Okay, that might work, but if you run into any problems with HTTPS and HTTP URLs mapping incorrectly (for example, it thinks /secure/foo is /foo or vice-versa), then try mapping both at the root of the domain (URL Path of / instead).

Hope that helps!

(Sep 08 '12 at 02:25) ryans ♦♦ ryans's gravatar image
showing 5 of 6 show all
Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×643
×6

Asked: Sep 07 '12 at 23:58

Seen: 481 times

Last updated: Sep 08 '12 at 02:25

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited