I wish to have multiple django installations. One at / (which is working fine) and one at /adam. The one at slash adam is redirected by apache correctly, until you try and visit an app. E.g. /admin works but /adam/admin does not work. I get the error:
Page not found (404)
Request Method: GET
Request URL: http://[CENSORED]/adam/
Using the URLconf defined in bms.urls, Django tried these URL patterns, in this order:
^admin/doc/
^admin/
The current URL, , didn't match any of these.
Notice the empty commas. The apache virtual host is:
<VirtualHost *:80>
ServerName [CENSORED]
DocumentRoot /home/user/bms
Alias /static/admin/ /usr/local/lib/python2.7/site-packages/Django-1.3-py2.7.egg/django/contrib/admin/media/
<Directory /home/user/bms/apache>
Order allow,deny
Allow from all
</Directory>
<Directory /home/ajt1g09/bms/apache>
Order allow,deny
Allow from all
</Directory>
WSGIDaemonProcess bms user=user group=user processes=2 threads=25 python-path=/usr/local/lib/python2.7/site-packages
WSGIProcessGroup bms
WSGIScriptAliasMatch ^/adam(.*) /home/ajt1g09/bms/apache/django.wsgi
WSGIScriptAlias / /home/user/bms/apache/django.wsgi
</VirtualHost>
And the django.wsgi file in ajt1g09/bms/apache:
import os
import sys
path = '/home/ajt1g09/bms'
if path not in sys.path:
sys.path.append(path)
sys.path.append('/usr/local/lib/python2.7/site-packages')
sys.path.append('/home/ajt1g09')
os.environ['DJANGO_SETTINGS_MODULE'] = 'bms.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
And finally, the urls.py file in ajt1g09/bms (clearly showing /admin is there):
from django.conf.urls.defaults import patterns, include, url
#Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover()
urlpatterns = patterns('', # Examples: # url(r'^$', 'bms.views.home', name='home'), # url(r'^bms/', include('bms.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation: url(r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: url(r'^admin/', include(admin.site.urls)), )
I have no idea what the problem is.
You shouldn't be using:
WSGIScriptAliasMatch ^/adam(.*) /home/ajt1g09/bms/apache/django.wsgi
Just use:
WSGIScriptAlias /adam /home/ajt1g09/bms/apache/django.wsgi
The WSGIScriptAliasMatch will not work as written because you haven't re substituted the matched part from back into last argument. Ie.,
WSGIScriptAliasMatch ^/adam(.*) /home/ajt1g09/bms/apache/django.wsgi$1
You should though simply not be using WSGIScriptAliasMatch. That is for advanced use cases only and requires you be very careful in using it because how you use it can impact what SCRIPT_NAME/PATH_INFO are set to when passed to application and it is those that urls.py matching is based off.