Django + mod_wsgi url rewriting issue

36 views
Skip to first unread message

Sebastiaan Snoeckx

unread,
Sep 18, 2012, 5:26:52 PM9/18/12
to django...@googlegroups.com
Hello list

I used mod_wsgi to setup my site to rewrite urls according to
<http://serverfault.com/a/126188> but now my app doesn't seem to follow
its urlconf anymore. Every single request to the wsgi application just
returns my default (index) view. example.com/, example.com/a/,
example.com/foo/bar... it's all my default view, no other views work...

Is there some setting (I heard something about a faulty SCRIPT_NAME? but
I'm unsure about that) I'm missing or how does Django find out the
original request from the rewritten URI?

Maybe I'm not very clear, so feel free to ask for more information.

Thanks in advance




Rafael E. Ferrero

unread,
Sep 19, 2012, 8:27:16 AM9/19/12
to django...@googlegroups.com
I use something like that... i mean, for example if /foo/bar must to
execute with django the url must to be example.com/site.wsgi/foo/bar
(continue with the example of serverfault)... if you follow
example.com/foo/bar apache use your statics files.

(this part of my production virtualhost)

WSGIDaemonProcess domain.com processes=2 threads=15 display-name=%{GROUP}
WSGIProcessGroup domain.com
WSGIScriptAlias /dj /home/path/to/site/django/wsgi/django.wsgi

Alias /media/ /home/path/to/site/django/src/project/media/
Alias /static/admin/ /home/path/to/site/django/src/project/static/admin/

(End Virtualhost example)

Following my example i have an urlconf to see news:
url( r'^/news/', 'news-site' ),

but clients must to put http://www.mydomain.com/dj/news/ so apache
see that you put /dj in yours url... so execute django.wsgi... urlconf
see news in the url so execute news-site view.


Sorry about my english i hope that help you


2012/9/18 Sebastiaan Snoeckx <sebastiaa...@gmail.com>:
--
Rafael E. Ferrero
Claro: (03562) 15514856

Sebastiaan Snoeckx

unread,
Sep 20, 2012, 12:58:18 PM9/20/12
to django...@googlegroups.com

I use something like that... i mean, for example if /foo/bar must to
execute with django the url must to be example.com/site.wsgi/foo/bar
(continue with the example of serverfault)... if you follow
example.com/foo/bar apache use your statics files.

(this part of my production virtualhost)

WSGIDaemonProcess domain.com processes=2 threads=15 display-name=%{GROUP}
WSGIProcessGroup domain.com
WSGIScriptAlias /dj /home/path/to/site/django/wsgi/django.wsgi

Alias /media/ /home/path/to/site/django/src/project/media/
Alias /static/admin/ /home/path/to/site/django/src/project/static/admin/

(End Virtualhost example)

Following my example i have an urlconf to see news:
url( r'^/news/', 'news-site' ),

but clients must to put http://www.mydomain.com/dj/news/  so apache
see that you put /dj in yours url... so execute django.wsgi... urlconf
see news in the url so execute news-site view.


Sorry about my english i hope that help you
 >

Well... first of all, my static files are not in separate '/static/' directories or on a separate server or anything (hence the RewriteCond), and secondly, the problem is that even when I do "example.com/site.wsgi/foo/" it still won't work and i only get my default view... always... as a matter of fact, instead of returning a Django error when I enter a known bogus address, it still shows my default view.

Btw, I'm unsure about the terminology here, but 'default view' is simply "url(r'', 'app.views.show_index')" which shouldn't actually match anything (just an empty GET) -- meaning the GET request is stripped by Django for some reason? that or there's a mistake in my RewriteRule.

I'm really stuck with this... :(
Reply all
Reply to author
Forward
0 new messages