Blog from the Loft

Thoughts without walls

Blog from the Loft header image 2

Serving favicon in an Django App using Apache

August 13th, 2008 · 2 Comments · django

I got a free few minutes to work on my own site here. Since I migrated the site from all static pages to Django served, I still haven’t put back the favicon icon back onto the site. The sites runs under a virtual host in apache2 at WebFaction. This is what you need to put in your httpd.conf file:

alias /favicon.ico /home/your-home/your-app-etc/static/image/favicon.ico

<LocationMatch "\.(jpg|css|gif|pdf|ico)$">
SetHandler None
</LocationMatch>

The alias line tells apache to go look for the favicon.ico file at a static location of your choice.

The LocationMatch directives tell apache to not run those files thru the Django engine.

Tags:

2 responses so far ↓

  • 1 Andrew // Nov 2, 2008 at 10:55 pm

    Hey there. I tried to do this following your instructions, but it’s not working for me. I put the appropriate lines in httpd.conf and restarted apache.

    Do I have to do something else besides update httpd.conf? You can email me back if you are inclined at andrewljohnson [at] gmail.com

  • 2 and3k // Jan 1, 2009 at 11:14 am

    I’m using FastCGI for all my django sites and there’s an even simpler solution: Adding the following does the trick:

    RewriteRule ^/favicon.ico$ /media/favicon.png [QSA,L,PT]

Leave a Comment