Q:

URLs redirection problems deploying a working django app in apache (via mod_wsgi)

I've a django app that works perfectly under the django development server. I'm trying to deploying it in apache2.2 using the mod_wsgi and I have errors.
In the httpd.conf file I "mounted" my app under the root /myapp using:
<IfModule wsgi_module>
    WSGIScriptAlias /myapp my_path_to_wsgi_module/django.wsgi
    WSGIScriptReloading On
    WSGIDaemonProcess djangoapps processes=10 threads=1 maximum-requests=500 display-name=my-wsgi
    WSGIProcessGroup djangoapps
</IfModule>

I've followed the standard indication to prepare django.wsgi. Now, I can reach the main page template of my app but it seems to have redirection errors. The "/myapp" root is not inserted automatically on ULRs redirection requests. Request from the main page template to some modules in views.py via urls.py cannot be correctly delivered.
apache access log:
127.0.0.1 - - [21/Feb/2011:16:11:44 +0100] "GET /myapp/ HTTP/1.1" 200 1795  
127.0.0.1 - - [21/Feb/2011:16:11:46 +0100] "GET /api/dir HTTP/1.1" 404 205

"/api/dir" doesn't exist, it should be matched from a pattern in urls.py, but id doesn't.
apache error log:
[Tue Feb 21 16:11:46 2011] [error] [client 127.0.0.1] File does not exist: /home/my_path_to_django_app_superfolder/api, referer: http://127.0.0.1/myapp/

I've spent more than 2 days with it, please can somebody help?

A:

Finally I found the error. It was not connected to httpd.conf file but to how URLs are specified both to django urls.py file and to templates. As I mounted myapp in this way:
WSGIScriptAlias /myapp my_path_to_wsgi_module/django.wsgi

I was believing that URLs specified in django template files should carry an initial slash, like this:
'/api/dir'
It results that in this way the application works only on django development server but not on apache.
Instead if you use URLs without initial slash like:
'api/dir'
The app works correctly both on django development server and on apache!
You must avoid using starting slashes even on pattern matching of django urls.py file:
like this: (r'^api/dir$', 'available_services') 
and NOT like this: (r'^/api/dir$', 'available_services')
Maybe this is an obvious thing for expert django users but if you're novice like me, this can make you loose a certain amount of time because it's a hard problem to be detected.

