Apache mod_rewrite rewritecond -U工作,然后没有

时间:2016-02-09 21:39:27

标签: apache mod-rewrite proxy

我尝试通过将当前服务器上的某些内容与代理匹配的请求传递给代理来查看它是否应该很容易。当在服务器上查找物理文件和目录时规则工作正常,但是当查找不在文件系统上的存在的位置或者来自php,或者java或者其他什么的某种其他路由控制时,这些规则很奇怪。所以" /重定向"不存在作为文件或目录,然后它用-U找到它并且也失败,好,直到它命中代理并返回并确定它实际上确实存在于代理上一切都很好,然后没有任何实际代理。显然我需要在这里做点其他事情,但是我被卡住了,文档和示例并没有真正帮助我。我可能只是在今天晚些时候有一个大脑炸药的案例。

RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}$1 -f [OR]
RewriteCond %{DOCUMENT_ROOT}$1 -d [OR]
RewriteCond %{REQUEST_URI} -U
RewriteRule (.*) - [S=2]
RewriteRule ^(.*)$ http://localhost:3000$1 [P,L]

以下是日志的输出

init rewrite engine with requested uri /redirect
applying pattern '(.*)' to uri '/redirect'
RewriteCond: input='/opt/apache/htdocs/www/redirect' pattern='-f' => not-matched
RewriteCond: input='/opt/apache/htdocs/www/redirect' pattern='-d' => not-matched
init rewrite engine with requested uri /redirect
applying pattern '(.*)' to uri '/redirect'
RewriteCond: input='/opt/apache/htdocs/www/redirect' pattern='-f' => not-   matched
RewriteCond: input='/opt/apache/htdocs/www/redirect' pattern='-d' => not-   matched
RewriteCond: input='/redirect' pattern='-U' => not-matched  <-- OK GOOD
applying pattern '^(.*)$' to uri '/redirect'
rewrite '/redirect' -> 'http://localhost:3000/redirect'  <-- GOING TO LOOK
forcing proxy-throughput with http://localhost:3000/redirect <-- GOING TO LOOK
go-ahead with proxy request proxy:http://localhost:3000/redirect [OK] <-- FOUND
RewriteCond URI (-U) check: path=/redirect -> status=200  <-- OK I GUESS I THOUGHT IT WOULD BE A REDIRECT STATUS CODE
RewriteCond: input='/redirect' pattern='-U' => matched  <-- WAIT, WHY?
pass through /redirect  <-- SIGH

0 个答案:

没有答案