全部。所以我正在运行 Apache 2.2。我有一个用于 Django 应用程序的 VirtualHost(通过 mod_wsgi)以及一个位于子目录中的 PHP 应用程序。通常,这没有问题。你可以Alias /subdir /path/to/phpapp
跟着WSGIScriptAlias / /path/to/django.wsgi
.
但是,复杂的是,这个 PHP 应用程序使用 mod_rewrite 来实现“花式 URL”,这只是意味着 '/subdir/foo/bar' 将被重写为类似于 '/subdir/index.php?path=foo/bar' .
这是我的配置:
<VirtualHost *:80>
ServerName [snip]
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
Alias /phpapp/ /home/ubuntu/phpapp/
<Directory /home/ubuntu/phpapp>
Order allow,deny
Allow from all
RewriteEngine on
RewriteCond $1 !^(index\.php|img|bin)
RewriteRule ^(.*)$ index.php?__dingo_page=$1 [PT]
</Directory>
WSGIDaemonProcess foo user=ubuntu
WSGIProcessGroup foo
WSGIScriptAlias / /home/ubuntu/djangoapp/apache/django.wsgi
<Directory /home/ubuntu/djangoapp/apache>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
问题是无论何时发生重写(例如,我尝试转到 /phpapp 或 /phpapp/foo),请求都会由 WSGI 处理,我会看到我的 Django 站点的 404 页面。如果地址通过(例如,我转到/phpapp/index.php),则它由PHP处理并正常工作。我想也许将[PT]
标志添加到我的 RewriteRule 可以解决这个问题,但它似乎对选择哪个处理程序没有任何影响。我还尝试SetHandler application/x-httpd-php
了 PHP 应用程序的目录部分。
我需要 Django 应用程序继续处理任何没有特别别名为其他东西的 URL。必须有办法使这项工作!谢谢。