<img alt="My Image" src="/media/img/myimage.png"/>
<link rel="stylesheet" href="/media/css/mysheet.css" type="text/css"/>
and so on.
This can be easily achieved by replacing in apache's configuration file:
<Location "/media/">
SetHandler None
</LocationMatch>
by
<LocationMatch "/((css|js|img|swf|pdf)/|favicon.ico)">
SetHandler None
</LocationMatch>
Of course you have to have all you media files in folders like css, js, img... or anything that you specify in last regular expression.
UPDATE: See this post before using this approach.
I'm pretty sure that they give an example in the docs on the Django site where they use something like the following:
ReplyDeleteSetHandler None
Which will snag any file with an extension that you've listed and stop mod_python from serving it .... much simpler than sorting your pngs and gifs into their own files : )
Hmmm .... your comment system ate my config (must have thought that it was html)
ReplyDeleteI had the following:
LocationMatch "\.(jpg|css|png|gif|js)$"
inside the tags, which is capturing the file extension of whatever is being served (rather than the folder).
I haven't seen it in the documentation, may be it's in the django book.
ReplyDeleteAnyway, I prefer to set it by directory. May be I have an image in my django directory that I don't want to share.
Thanks anyway for your comment, it's always good having more opinions, ideas...
Admin, please send me mail at ninoksa@gmail.com, thanks.
ReplyDeleteThanks for the tip!
ReplyDeleteThat was a well written article, very intereting,thank you for a good read.
ReplyDelete