title: Running the django admin over https using apache2
body: <p>I have a django web application that's running on apache 2.2.14 and I want to run the admin application over https.  </p>
  
  <p>Having read considerable discussions on using a proxy, writing middleware, running alternative wsgi scripts, the chaps in #httpd came to my rescue.  The solution is so simple, I was surprised I didn't find it online, so I'm curious to see if I've made some glaring assumptions or errors.</p>
  
  <p>One complication was that I also wanted to run one of my django apps in the site over https, that is everything on /checkout.</p>
  
  <p>Essentially, if a user requests a URI starting with /admin or /checkout on http, they are to be redirected to that URI but on https.  Conversely, if a user requests a URI that does not start with /admin or /checkout on https, they are to be redirected to that URI but on http.</p>
  
  <p>The key to solving this problem was to use Redirect and RedirectMatch directives in my VirtualHost configuration.</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
  
      ... host config stuff ...
  
      Redirect /admin https://www.mywebsite.com/admin
      Redirect /checkout https://www.mywebsite.com/checkout
  
  &lt;/VirtualHost&gt;
  &lt;VirtualHost *:443&gt;
  
      ... ssl host config stuff ...
  
      RedirectMatch ^(/(?!admin|checkout).*) http://www.mywebsite.com$1
  
  &lt;/VirtualHost&gt;
  </code></pre>