Configure mod_wsgi WSGIScriptAlias with mod_rewrite
- by Lazik
I want to redirect ex.com to www.ex.com but I still want www.ex.com/ to point to my app.wsgi without it showing up in the url.
When I use the conf below and I go to ex.com, I get a 404 error saying can't find www.ex.com/app.wsgi/
If I change the WSGIScriptAlias / /var/www/vhosts/ex/app.wsgi to
WSGIScriptAlias /app.wsgi /var/www/vhosts/ex/app.wsgi
Then all my url look like www.ex.com/app.wsgi/blabla/...
Is it possible to use some kind of rule to redirect ex.com to www.ex.com and still keeping / as the app.wsgi root?
my conf file
<VirtualHost *:80>
ServerName www.ex.com
ServerAlias ex.com *.ex.com
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
WSGIDaemonProcess ex user=www-data group=www-data processes=1 threads=5
WSGIScriptAlias / /var/www/vhosts/ex/app.wsgi
<Directory /var/www/vhosts/ex>
WSGIProcessGroup ex
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>