On Oct 15, 7:46 am, Daniel Hilton <daniel.hil...@gmail.com> wrote:
> 2009/10/14 Jani Tiainen <rede...@gmail.com>:

> > Chris Withers kirjoitti:
> >> Hi All,
>
> >> I need to host my django project from /some/folder in my apache instance.
>
> >> I have the following:
>
> >> WSGIScriptAlias /some/folder /path/to/django.wsgi
>
> >> Does this now mean I have to prefix all my entries in urls.py with
> >> /some/folder?
>
> >> I hope not, but give that going to:
>
> >>http://myserver/some/folder
>
> >> ...gives me a 404 unless I do, I'm not hopeful.
>
> >> What am I doing wrong?
>
> > "nothing".
>
> > Term is called "suburl deployment" and I've done it (for testing purposes).
>
> > Apache config:
>
> > RewriteEngine On
>
> > #add missing trailing slash if needed
> > RewriteRule    ^/<suburl>$  /<suburl>/  [R]
>
> > #WSGI alias[[BR]]
> > WSGIScriptAlias /<suburl> absolute_path_to_wsgi_file.wsgi[[BR]]
>
> > And if you're using authentication in your app you must provided full
> > absolutely URL to login page, I've done it settings.py:
>
> > LOGIN_URL='/<suburl>/login/'
>
> > And that's it. Of course you have to keep all your apps using hardcoded
> > urls but use reverse url finding always.
>
> Does this enable you to run a django project only on a certain url?
>
> So, say for example you've got a legacy php site that has the
> siteroot, could you run a django app off of /<app>/ ?

Yes. Except that Django will see itself being mounted at the sub URL.
Since urls.py will not mention the sub URL, that isn't generally a
problem.

There are also a number of ways of configuring things so that the
Django application still appears to be mounted at the root of the site
but with a subset of URLs being forwarded through to it. This can be
explicitly dictated, or even done such that everything goes through to
Django except for where static files exist in DocumentRoot
corresponding to PHP and static files. Thus, in effect the file based
resources take precedence. Remove a static file resource and it will
automatically then push that URL through to Django with no change in
configuration.

Flexible configuration is one of Apache/mod_wsgi's strong points and
there are many things one can do that the majority wouldn't ever need.

Graham
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to