Reputation: 2777
What I'm trying to accomplish is to have Apache serve all content at mysite.com/ and have Django handle everything under mydomain.com/signup
and mydomain.com/login
.
The problem is that right now the user has to browse to mydomain.com/mysite/signup
or mydomain.com/mysite/login
for things to work. I want to get rid of the mysite part of the URLs.
I created a project with
django-admin startproject signup mysite
cd mysite
django-admin startapp login
I ended up with this directory structure.
mysite
├── login
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── migrations
│ │ └── __init__.py
│ ├── models.py
│ ├── tests.py
│ ├── urls.py
│ └── views.py
├── manage.py
└── signup
├── __init__.py
├── settings.py
├── urls.py
├── views.py
└── wsgi.py
I have the following urlpatterns in signup/urls.py
urlpatterns = [
url(r'^signup/', views.index, name='index'),
url(r'^login/', include('login.urls')),
url(r'^admin/', admin.site.urls),
]
I have Apache mod_wsgi installed and working and have this WSGIScriptAlias in my virtual host file.
WSGIScriptAlias /mysite /usr/local/www/wsgi-scripts/mysite/signup/wsgi.py process-group=mysite.com
When the user goes to either mydomain.com/mysite/signup
or mydomain.com/mysite/login
everything works.
What I want to do is get rid of the 'mysite'
part of the above URLs so the user just has to browse to mydomain.com/signup
or mydomain.com/login
.
I've tried
WSGIScriptAlias /signup /usr/local/www/wsgi-scripts/mysite/signup/wsgi.py process-group=mysite.com
WSGIScriptAlias /login /usr/local/www/wsgi-scripts/mysite/signup/wsgi.py process-group=mysite.com
But that doesn't work because either Apache or mod_wsgi strips off the 'signup' or 'login' part before it gets to Django and Django just thinks the user is looking for '/'.
Any suggestions?
Thanks
Upvotes: 0
Views: 51
Reputation: 58523
Try using:
WSGIScriptAlias /signup /usr/local/www/wsgi-scripts/mysite/signup/wsgi.py/signup process-group=mysite.com application-group=%{GLOBAL}
WSGIScriptAlias /login /usr/local/www/wsgi-scripts/mysite/signup/wsgi.py/login process-group=mysite.com application-group=%{GLOBAL}
Note how the mount point is added after wsgi.py
. The application-group
option is also added to ensure you only get one instance of your Django application in the process.
The other way is for any static files to be handled by Apache, with everything else handled by the WSGI application. How to do this is documented towards end of section 'The Apache Alias Directive' in:
Upvotes: 1
Reputation: 599590
If you don't want a prefix, don't use one.
WSGIScriptAlias / /usr/local/www/....
Upvotes: 0