Monday, October 1, 2012

Re: non-root SCRIPT_NAME, mod_wsgi and RewriteRule

is it a problem with the trailing slash?

On Sun, Sep 30, 2012 at 7:57 AM, Sebastiaan Snoeckx <sebastiaan.snoeckx@gmail.com> wrote:
I have my Django website and my static files deployed under the same directory (i.e. no separate 'static' directory), according to the following Apache RewriteRule:

        RewriteEngine on
        RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
        RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
        RewriteRule ^.*$ /django/$1  [QSA,PT,L]

        WSGIScriptAlias /django/ /var/www/domain.com/django/site/wsgi.py

My site-wide urlconf looks like this:

        urlpatterns = patterns('',
                url(r'^blog/', include('blog.urls')),
                url(r'', include('home.urls')),
        )

With my app-specific urlconf ('home.urls') is simply this:

        urlpatterns = patterns('home.views',
                url(r'^(?P<uri>[a-z0-9-]+)/?$', 'page_by_uri'),
                url(r'^$', 'index'),
        )

So when I visit my site domain.com I should see the index view (which it does), and when I visit domain.com/foo I should see the page_by_uri('foo') view, *which it doesn't*. Instead, it shows the index view. (And I thought it should give an error!)

Having surfed around a little bit, I reckon it's got something to do with Django's handling of SCRIPT_NAME (which should be equal to the mount point, in my case '/dj'). Various solutions are proposed, generally involving adding the mount point to my urlconf (bad!) until I tried it and it doesn't even work...

Basically, how in the name of all that is holy and sacred can I get this to work?!

Thanks in advance


--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment