I'm using the Django alias site_media redirect to access static files
on my server. I have an aspect to my django application whereby the
user can upload his own files and then access those files to include
them in newsletters etc...

The problem of course is that the user will upload files to /libs/
media/userfiles, but then when it comes to the time to access those
files, /libs/media/userfiles/file.jpg will return a 404 because the
file can only be accessed at /site_media/userfiles/file.jpg

Httpd.conf :

# The django static file redirect
Alias /site_media /home/babo/django/mobiit/libs/media/

My erstwhile solution was to use a Rewrite rule so that the user could
access /site_media/ from /libs/media ...

Httpd.conf:

 RewriteEngine On
 RewriteLog "/tmp/mobiit/rewrite.log"
 RewriteLogLevel 9
 RewriteRule ^/libs/media/(.*)$ /site_media/($1)

Log Output:

(2) init rewrite engine with requested uri /libs/media/userfiles/image/
file.jpg
(3) applying pattern '^/libs/media/(.*)$' to uri '/libs/media/
userfiles/image/file.jpg'
(2) rewrite /libs/media/userfiles/file.jpg -> /site_media/(userfiles/
image/file.jpg)
(2) local path result: /site_media/(userfiles/image/file.jpg)
(2) prefixed with document_root to /home/babo/django/mobiit/site_media/
(userfiles/file.jpg)
(1) go-ahead with /home/babo/django/mysite/site_media/(userfiles/image/
file.jpg) [OK]

As you can see from the last line, the rewrite will add the document
root to the file path. In my case the file path is purely fictional
and hence there's a problem using the rewrite.

So what I did at that stage was put a soft link in the /mysite
directory that should have take the /home/babo/django/mysite/
site_media/ to /home/babo/django/mysite/libs/media instead.
Unfortunately this doesn't work either though ....

ln -s libs/media/ site_media

Has anyone else encountered this problem ?

Thanks


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to