Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have set up an Apache server with WSGI/Django on it, and everything works fine -- html, css -- but when I try to request an image file, like png, it returns 403 Forbidden. The configuration is as follows:


WSGIScriptAlias / /var/djangoblog/myDjangoBlog/wsgi.py

<Directory /var/djangoblog/myDjangoBlog>
<Files wsgi.py>
    Order deny,allow
    Allow from all

Alias /robots.txt /var/www/robots.txt
Alias /favicon.ico /var/www/favicon.ico

Alias /static/ /var/djangoblog/static/
Alias /media/ /var/djangoblog/media/

<Directory /var/djangoblog/static>
    Order allow,deny
    Allow from all

<Directory /var/djangoblog/media>
    Order allow,deny
    Allow from all

I also tried to allow from all in httpd.conf, but no luck.

Could you please help me?

share|improve this question
up vote 1 down vote accepted

Most likely, this is a posix-permissions-issue or an selinux-context-issue. I would check to see that the png files in question are readable to your web-server user/group and are permissions 755. To check selinux contexts, try an "ls -RZl /var/djangoblog" and see that the contexts listed are the same for files that are served and files that are not.

After that, this is far less likely. Apache might be filtering the files, doubtful by default but in the huge open source wilderness where we don't know what distro you are on, it is a possibility. (debian, CentOS?)

Check httpd.conf and any conf.d/ like files/directories (anything that contains apache directives) especially for a line such as <FilesMatch ".(gif|jpg|jpeg|png)$"> which could be matching and rejecting the requests for those png files. These apache global files might be overaliasing the sites-enabled/default instance also, if they incidentally contain any /media/ // aliases.

share|improve this answer
Thanks, I figured it out. As you said, it was a permission issue. The file I tried to serve was marked no access to anybody else besides me and root. – FLamparski May 18 '12 at 18:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.