Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a site that is only partially Django driven. I want the Django portion to be anything under Anything not in this directory should get served by apache as usual.

I also must use fastcgi on my server.

How would I set my .htaccess and urls to get this to work?

share|improve this question

migrated from Oct 6 '09 at 3:30

This question came from our site for professional and enthusiast programmers.

You can try something along the lines of this:

# mod_python for your site's apache config:

<VirtualHost *>
    # ...
    <Location "/register/">
        PythonHandler django.core.handlers.modpython
        PythonPath "['/your/project/path'] + sys.path"
        SetEnv PYTHON_EGG_CACHE /tmp/trac-eggs/myproject
        SetEnv DJANGO_SETTINGS_MODULE myproject.settings
        SetHandler python-program
        PythonDebug Off
        PythonAutoReload Off
    # ...

Or possibly,

# mod_wsgi for your site's apache config:

<VirtualHost *>
    # ... 
    WSGIScriptAlias /register/ "/path/to/myproject.wsgi"
    # ...
share|improve this answer
mod_python is deprecated.mod_wsgi is the way to go – Kristaps Mar 10 '11 at 11:29

Something like:

  RewriteEngine On
  RewriteRule ^/(media.*)$ /$1 [QSA,L,PT]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^/register/(.*)$ /mysite.fcgi/$1 [QSA,L]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.