views:

104

answers:

5
Alias /media/ /home/matt/repos/hello/media
<Directory /home/matt/repos/hello/media>
Options -Indexes
Order deny,allow
Allow from all
</Directory>
WSGIScriptAlias / /home/matt/repos/hello/wsgi/django.wsgi

/media is my directory. When I go to mydomain.com/media/, it says 403 Forbidden. And, the rest of my site doesn't work because all static files are 404s. Why? The page loads. Just not the media folder.

Edit: hello is my project folder. I have tried 777 all my permissions of that folder.

+3  A: 

You have Indexes disabled, so Apache won't generate a listing of the files when you request the directory /media (instead, it shows the 403 Forbidden error). Try accessing a file directly within there, e.g.: http://localhost/media/some_image.jpg

Mike Mueller
I tried accessing it. It's 404.
TIMEX
@alex: Do you actually have a file called `some_image.jpg` in `/home/matt/repos/hello/media`?
mojbro
Yes, I do. And it's a 404. I'm guessing it's something to do with the Alias, since Apache accesses my page fine, and it loads. Only the static stuff is 404.
TIMEX
A: 

If memory serves me correctly, Apache runs under it's own user account. Are you sure that this account has the correct permissions to that directory?

saret
Yes. It accesses everything else fine. Just not that media folder.
TIMEX
A: 

its all about the dash Options -Indexes and here is a complete editon to yours

 Alias /media/ /home/matt/repos/hello/media
<Directory "/home/matt/repos/hello/media">
    Options Indexes
    AllowOverride all
    Order Deny,Allow
    Allowfrom all
</Directory

and i'd love to add

AllowOverride all

Feel free to delete it:)

tawfekov
+1  A: 

It looks to me that WSGIScriptAlias / /home/matt/repos/hello/wsgi/django.wsgi tells to apache that everything under / should be handled by the specified WSGI script. This also includes /media. You should tell apache to exclude /media from that rule.

Try adding this to your config file:

<LocationMatch "^/media/">
SetHandler None
</LocationMatch>

Or craft a regex that matches everything but files under /media and replace your WSGIScriptAlias line with this:

WSGIScriptAliasMatch <regex> /home/matt/repos/hello/wsgi/django.wsgi
m000
A: 

I solved it. I missed a trailing slash. after media/

TIMEX