I have a Django site set up that uses the Django admin panel, prefixed with /media/
, as well as static site content in a directory called /static/
. The admin media stuff, of course, lives within the Django package, and the site's static content is stored along with the Python code for the site.
Currently, my public_html
just contains appropriately-named symlinks to the directories that actually hold the static content, as follows:
~/public_html/
.htaccess
media -> $HOME/usr/lib/python2.4/site-packages/django/contrib/admin/media/
site.fcgi
site -> $HOME/mysite/public/static/
And these are the rewrite rules I'm using in my .htaccess
file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ site.fcgi/$1 [QSA,L]
However, using symlinks in this way feels like a...hack, and it seems like I could use rewrite rules in the .htaccess
to avoid using symlinks. (I also want to eventually add a robots.txt
file and a favicon file, without having to add -- and maintain -- a bunch of symlinks.) Is this a good idea, and if so, how do I do that?
For future reference, I ultimately did something akin to how Rails projects are generally set up. My Django project contains a public
directory, which includes static site content, the FastCGI script, and the .htaccess
file, among other things, so it looks sort of like this:
~/
django/
public/
.htaccess
content/
favicon.ico
media@ -> /symlink/to/django/admin/media/
site.fcgi
static/
And then, ~/public_html
is just symlinked to ~/django/public
. Everything works fine, so I'm happy.