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 ar开发者_JAVA百科e 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.
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
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
I solved it. I missed a trailing slash. after media/
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:)
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?
精彩评论