ProxyPassMatch和mod_rewrite的操作顺序

我在Apache文件夹模式下遇到了Apache 2.4,PHP-FPM和Wordpress Multi用户的情况。

所有非* .php文件都可以在子文件夹中正常工作,就像主要的example.com/subblog/ url一样,但是任何带有.php的文件,如example.com/subblog/wp-login.php都会失败,并且File Not Found来自PHP-FPM。

mod_rewrite文件是:

RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] # uploaded files RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L] # add a trailing slash to /wp-admin RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [PT] RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [PT] RewriteRule . index.php [PT] 

这基本上是推荐的文件,但有些[L]用[PT]代替,试图使其正常工作。

PHP-FPM被调用:

 ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:21358/home/northest/public_html/$1 

所以PHP-FPM正试图加载example.com/subblog/wp-login.php(这不存在),当mod_rewrite应该改变它example.com/wp-login.php(这确实存在)。

我已经读过PT应该被用来允许ProxyPassMatch拿起重写,但它仍然看起来像ProxyPassMatch在mod_rewrite到达之前执行。 我打开了mod_rewritedebugging,它不输出* .php文件的任何debugging信息。

这里的解决scheme是什么使得它始终在ProxyPassMatch之前处理mod_rewrite规则?

find解决scheme 为了得到它的工作,我不得不稍微修改一下重写规则,而不是通过.htaccess将它们包含在Apacheconfiguration文件中。

Apache也开始尝试将index.html重写到需要更改DirectoryIndex的所有文件夹的末尾,以便index.php处于开始状态。

最后,所有的重写规则都需要绝对加上DOCUMENT_ROOT,然后重写以/

 DirectoryIndex index.php index.html RewriteEngine On RewriteRule ^index\.php$ - [L] # uploaded files RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L] # add a trailing slash to /wp-admin RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -f [OR] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^/[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) /$1 [PT] RewriteRule ^/[_0-9a-zA-Z-]+/(.*\.php)$ /$1 [PT] RewriteRule . /index.php [PT]