I am developing a Django application which works fine locally. In production, the application will be served from a relative path, such as www.example.com/app/.
I am using Apache with mod_wsgi, and I have configured Apache to serve the application from the relative URL:
WSGIScriptAlias /app /path/to/my/modwsgi.py
WSGIDaemonProcess app display-name=app_wsgi
Unfortunately, I get an Error 404. The debug information, though, is pretty mysterious. If I try to get www.example.com/app/myurl/, Django says
Using the URLconf defined in apps.urls, Django tried these URL patterns, in this order:
^myurl/$
...
The current URL, myurl/, didn't match any of these.
It seems that Django – correctly – infers that the path requested is myurl/, and not app/myurl/. But, even though myurl/ clearly matches ^myurl/$, it does not find a match.
I have also tried to add the setting
FORCE_SCRIPT_NAME = '/app'
but nothing changes – the error message remains identical.
The debug information lies :-/ Trying with more permissive regexs in the URL conf; iwas able to get a page. From there I could print
request.path, and it turned out to beapp/myurl/.To make it work, I had instead to put