|Version 2 (modified by 10 years ago) (diff),|
Using mod_rewrite with Django on apache
here are a few gotchas with using django+mod_rewrite (sure, your urls are clean, but sometimes it's easier have a root url in the filesystem and a "directory" for mod_python setting !
1) when mod_rewriting to a 'in django' part of your url space, be sure to use [PT], or at the end, the url will be understood as a filepath and not given back to mod_python handler. The [PT] option of a mod_rewrite rule ensures that.
2) Beware the trailing slashes ! Django, by default (there is an option) adds a trailing / to urls without it, by REDIRECTING to the url+/. So if you mod_rewrite an url to your django one, don't forget the trailing / or disable adding them, because else mod_rewrite will rewrite url to new_url and then django will redirect to newurl+/ and thus you'll loose your neat urls in the address bar.