I have a site that is only partially Django driven. I want the Django portion to be anything under http:www.mydomain.com/register. 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?

migrated from stackoverflow.com 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"
    # ...
  • 2
    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]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy