1

in response to: How can Django/WSGI and PHP share / on Apache?

Hello,

could you please post the complete config file from /sites-available

I am having a problem seems like rewrite engine redirects all requests to django, so static and php files are not served and instead i see the django 404 page. If I get rid of rewrite rule then static files and php works.

here is my apache config file from /sites-available

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /home/www/django
    <Directory />
            Options +FollowSymLinks ExecCGI Indexes
            AllowOverride None
            DirectoryIndex index.php
            AddHandler wsgi-script .wsgi


    </Directory>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /mysite.wsgi/$1 [QSA,PT,L]

~

and my .wsgi file:

import site

site.addsitedir('/home/user/.virtualenvs/url.com/lib/python2.6/site-packages')

import os, sys

path = '/home/www/django' if path not in sys.path: sys.path.append(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

sys.path.append(path + '/mysite') import django.core.handlers.wsgi

_application = django.core.handlers.wsgi.WSGIHandler()

import posixpath def application(environ, start_response):

# Wrapper to set SCRIPT_NAME to actual mount point.
environ['SCRIPT_NAME'] = posixpath.dirname(environ['SCRIPT_NAME'])
if environ['SCRIPT_NAME'] == '/':
    environ['SCRIPT_NAME'] = ''
return _application(environ, start_response)

the document root directory on disk (/home/www/django) contains php files, images, and the mysite.wsgi file.. thanks for your help

1 Answer 1

2

figured it out

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /home/webdev/domains/handtrackers.com/django

    <Directory /home/www/django>

            #Options +FollowSymLinks +SymLinksIfOwnerMatch ExecCGI Indexes
            AllowOverride None
            AddHandler cgi-script .cgi
            AddHandler application/x-httpd-php .php
            AddHandler wsgi-script .wsgi

            Order allow,deny
            Allow from all

            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$ /mysite.wsgi/$1 [QSA,PT,L]

    </Directory>

but specifying any Option, like the commented out one... will result in:

"Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden:"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .