Apache 2.4 mod_rewrite和Location ProxyPass

时间:2015-10-10 21:28:58

标签: apache mod-rewrite

我的配置看起来像这样:

RewriteEngine On
RewriteRule ^/data/(images/.*) /data-server/$1 [PT]
<Location /data/>
    ProxyPass ajp://localhost:8009/data/
    Order Deny,Allow
    Allow from all
</Location>
<Location /data-server/>
    ProxyPass ajp://localhost:8009/data-server/
    Order Deny,Allow
    Allow from all
</Location>
...

但是,带有直通标志[PT]的RewriteRule无法正常工作 - httpd最终会在htdocs中查找该文件,而不是使用ProxyPass指令。

有没有办法在重写过程中执行真正的直通,强制httpd遵循所有逻辑,包括位置部分?

mod_rewritemod_proxy从不一起工作?

1 个答案:

答案 0 :(得分:0)

这似乎是2.4中的错误。从2.2迁移到2.4时,我遇到了类似的问题。我不得不将ProxyPass指令从Location部分拉出来,如下所示:

RewriteEngine On
RewriteRule ^/data/(images/.*) /data-server/$1 [PT]
<Location /data/>
    Order Deny,Allow
    Allow from all
</Location>
ProxyPass /data/ ajp://localhost:8009/data/
<Location /data-server/>
    Order Deny,Allow
    Allow from all
</Location> 
ProxyPass /data-server/ ajp://localhost:8009/data-server/