With Apache/mod_wsgi how can I redirect to ssl and require Auth?
Posted
by justin
on Stack Overflow
See other posts from Stack Overflow
or by justin
Published on 2010-03-25T18:40:50Z
Indexed on
2010/03/25
18:43 UTC
Read the original article
Hit count: 412
I have a Media Temple DV server hosting dev.example.com with django mounted at /. There is a legacy directory in my httpdocs I need to continue to serve at /legacy. But for this directory I need to redirect anyone coming over http over to https, then prompt for http basic auth.
In the virtual host conf, I'm pointing the root to a django application:
WSGIScriptAlias / /var/django-projects/myproject/apache/django.wsgi
<Directory /var/django-projects/myproject/apache>
Order allow,deny
Allow from all
</Directory>
Then I alias the legacy directory.
Alias /legacy/ /var/www/vhosts/example.com/subdomains/dev/httpdocs/legacy/
<Directory /var/www/vhosts/example.com/subdomains/dev/httpdocs>
Order deny,allow
Allow from all
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://dev.example.com/$1 [R,L]
</Directory>
This works. It isn't served by django, and the url redirects to https. However, it serves httpdocs/legacy instead of httpsdocs/legacy (where I have an .htaccess that prompts for auth.)
Any idea of how I can manage this?
© Stack Overflow or respective owner