django + apache2 + ssl: route URLs to PHP file?
I have django running with wsgi and apache.
I want to route some URLs to PHP part of the website. Because both the django/wsgi and PHP content requires SSL, I can't use virtual name hosting. How can I do this?
RewriteEngine in Apache config doesn't work, because there is no alternate NameVirtualHost to redirect to?
Can I have urls.py redirect to a PHP file, instead of a django application开发者_运维技巧 view?
Thanks!
You can put an alias to the php areas before your WSGIScriptAlias line in the virtual host section to get the desired result. I've just tested it:
alias /somefolder/ /srv/www.site.com/www/somefolder/
WSGIScriptAlias / /srv/www.site.com/myapp/app.wsgi
I can put php files into /srv/www.site.com/www/somefolder/ and they run as PHP.
Seems like it could be a major security issue as all requests are passed though Django when the Apache vhost has WGSI enabled. Just as it is not recommended to serve media though Django in production, this is likely not recommended.
That said, you might want to look at handling this like static media in PHP. Not sure that it will work, and I really would not recommend it, but you can give this a try:
urlpatterns = patterns(
(r'^php/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/abs/path/to/php'}),
)
精彩评论