Apache重写规则标志代理NS

Apache重写规则标志代理NS,apache,mod-rewrite,url-rewriting,rewrite,mod-proxy,Apache,Mod Rewrite,Url Rewriting,Rewrite,Mod Proxy,我正在尝试编写以下规则(参见注释) 即使使用NS标志,当我点击sub.example.org/foo时,我得到了太多的重定向,下面是RewriteLog applying pattern '^' to uri 'foo' rewrite 'foo' -> 'http://example.org/sub/foo' escaped URI in per-dir context for proxy, http://example.org/sub/foo -> http://example.

我正在尝试编写以下规则(参见注释)

即使使用NS标志,当我点击sub.example.org/foo时,我得到了太多的重定向,下面是RewriteLog

applying pattern '^' to uri 'foo'
rewrite 'foo' -> 'http://example.org/sub/foo'
escaped URI in per-dir context for proxy, http://example.org/sub/foo -> http://example.org/sub/foo
forcing proxy-throughput with http://example.org/sub/foo
go-ahead with proxy request proxy:http://example.org/sub/foo [OK]

applying pattern '^' to uri 'sub/foo'
rewrite 'sub/foo' -> 'http://sub.example.org/foo'
explicitly forcing redirect with http://sub.example.org/foo
escaping http://sub.example.org/foo for redirect
redirect to http://sub.example.org/foo [REDIRECT/301]
不断地

# Redirect example.org/sub/* to sub.example.org/* explicitly
RewriteCond %{REQUEST_URI} ^/sub(.+)$ [NC]
RewriteRule ^ http://sub.%{HTTP_HOST}%1 [L,R=301]

# Redirect sub.example.org/* to example.org/sub/* internally
RewriteCond %{HTTP_HOST} ^sub\.(.+)$ [NC]
RewriteRule - http://%1/sub%{REQUEST_URI} [L,P]
没有NS标志,只是冲刺。。。doh

# Redirect example.org/sub/* to sub.example.org/* explicitly
RewriteCond %{REQUEST_URI} ^/sub(.+)$ [NC]
RewriteRule ^ http://sub.%{HTTP_HOST}%1 [L,R=301]

# Redirect sub.example.org/* to example.org/sub/* internally
RewriteCond %{HTTP_HOST} ^sub\.(.+)$ [NC]
RewriteRule - http://%1/sub%{REQUEST_URI} [L,P]