Reputation: 3154
I have a Django app that I am porting from mod_python to mod_wsgi.
Under mod_python, I was able to map http://example.com/A and http://example.com/B to the same Django app. However, http://example.com/C (or anything not specified) would not invoke python, wsgi, or Django at all.
In addition, Django was still able to "see" the "/A" and "/B" at the start of the path.
In contrast, when I configure with mod_wsgi, I can get my Django app running with a simple WSGIScriptAlias directive:
WSGIScriptAlias / /path/to/my/wsgi.py
but this method lets my Django app handle "/C" (and any invalid path), which I do not want.
So I tried this:
WSGIScriptAlias /A /path/to/my/wsgi.py
WSGIScriptAlias /B /path/to/my/wsgi.py
This method invokes my Django app, but the Django app doesn't "see" the "/A" nor "/B" part of the url.
Finally, placing the WSGIScriptAlias
inside a <Location>
gives the error:
WSGIScriptAlias not allowed here
How can I configure mod_wsgi so that the first part of the path is passed to Django, and Apache will only pass a few paths to Django, and all such paths get passed to the same Django app?
Here is my old mod_python config, which worked:
<Location "/A/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE path.to.my.django.settings
</Location>
<Location "/B/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE path.to.my.django.settings
</Location>
Upvotes: 0
Views: 391
Reputation: 58523
Use:
WSGIScriptAlias /A /path/to/my/wsgi.py/A
WSGIScriptAlias /B /path/to/my/wsgi.py/B
Upvotes: 3