On Dec 9, 6:16 pm, Lakshman Prasad <scorpion...@gmail.com> wrote:
> You can just replace the regex ^/comments/$ with ^/sees/comments/$ within
> the urls.py
>
> Why can't you do that?

Because it will not work.

Based on description he is mounting Django application on /sees in
Apache, likely as:

  WSGIScriptAlias /sees /some/path/django.wsgi

This means that only URLs under /sees will get passed to Django.
Further, when mounted at sub URL, you should not have the mount point,
ie.. /sees, mentioned in urls.py patterns anyway. The patterns should
always be relative to the mount point. This is because PATH_INFO,
which is what is matched against the patterns, doesn't include /sees.
The /sees is in SCRIPT_NAME only for that configuration.

> > Hi all , I need some help understanding the mod rewrite module of apache .
> > What I wished to do want that i had a comments folder by the name of
> > /comments/ . Now i run a django project on /sees and i want all the call to
> > /comments/ be redirected to /sees/comments and than be handled by the wsgi
> > file but the rewriting is not happening is it possible to rewrite url and
> > than route it through wsgi script

A tricky way of handling the problem with mod_wsgi is to use (from
memory and untested):

  WSGIScriptAliasMatch ^/(sees|comments)(/.*)?$ /some/path/django/wsgi/
$1$2

In this case, because of how $1 also passed to last argument,
SCRIPT_NAME will actually be empty, meaning Django will think it is
actually mounted at root of web site. Only the sub URLs /sees and /
comments will get passed through to Django though.

Because the mount point has shifted, your urls.py do have to take that
into consideration though, and so you would have patterns starting
with:

  ^sees
  ^comments

Doing this avoids all the problems that can arise with using
mod_rewrite. It does mean though your primary sub URL mount point is
in the patterns in urls.py.

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-us...@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