How can Django/WSGI and PHP share / on Apache?
- by Mark Snidovich
I have a server running an established PHP site, as well as some Django apps.
Currently, a VirtualHost set up for PHP listens on port 80, and requests to certain directories are proxied to a VirtualHost set up for Django with WSGI.
I'd like to change it so Django handles anything not existing as a PHP script or static file.
For example,
/ -parsed by PHP as index.php
/page.php -parsed as PHP normally
/images/border.jpg -served as a static file
/johnfreep -handled by Django (interpreted by urls.py)
/pages/john -handled by Django
/(anything else) - handled by Django
I have a few ideas. It seems the options are 'php first' or 'wsgi first'.
set up Django on port 80, and set Apache to skip all the known PHP, CSS or image files. Maybe using SetHandler? Anything else goes to Django to be parsed by urls.py.
Set up a script referring everything to Django as a 404 handler on PHP. So, if a file is not found for a name, it sends the request path to a VirtualHost running Django to be parsed.