简体   繁体   English

django + apache2 + ssl:将URL路由到PHP文件吗?

[英]django + apache2 + ssl: route URLs to PHP file?

I have django running with wsgi and apache. 我的django与wsgi和apache一起运行。

I want to route some URLs to PHP part of the website. 我想将一些URL路由到网站的PHP部分。 Because both the django/wsgi and PHP content requires SSL, I can't use virtual name hosting. 因为django / wsgi和PHP内容都需要SSL,所以我不能使用虚拟名称托管。 How can I do this? 我怎样才能做到这一点?

  1. RewriteEngine in Apache config doesn't work, because there is no alternate NameVirtualHost to redirect to? Apache配置中的RewriteEngine不起作用,因为没有备用NameVirtualHost可以重定向到?

  2. Can I have urls.py redirect to a PHP file, instead of a django application view? 我可以将urls.py重定向到PHP文件,而不是django应用程序视图吗?

Thanks! 谢谢!

Seems like it could be a major security issue as all requests are passed though Django when the Apache vhost has WGSI enabled. 似乎这可能是一个主要的安全问题,因为当Apache vhost启用WGSI时,所有请求都通过Django传递。 Just as it is not recommended to serve media though Django in production, this is likely not recommended. 正如不建议通过Django在生产中为媒体提供服务一样,不建议这样做。

That said, you might want to look at handling this like static media in PHP. 就是说,您可能希望像在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'}),
)

You can put an alias to the php areas before your WSGIScriptAlias line in the virtual host section to get the desired result. 您可以在虚拟主机部分的WSGIScriptAlias行之前在php区域放置一个别名,以获得所需的结果。 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. 我可以将php文件放入/srv/www.site.com/www/somefolder/,它们以PHP的形式运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM