日期:2014-05-17  浏览次数:20950 次

apache如何动态绑定子目录,*.example.com,test.example.com=>/example.com/test.example.com
apache如何动态绑定子目录,
域名泛解析*.example.com
如果用户访问test.example.com
重写到这样的路径 /example.com/test.example.com

我在/example.com下放了一个.htaccess里面这样写的不行
RewriteEngine on
RewriteBase /
RewriteRule ^.*$ /%{SERVER_NAME}/$0 [L]


错误日志:
[Thu Jul 21 19:41:33 2011] [error] [client 127.0.0.1] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Thu Jul 21 19:41:33 2011] [debug] core.c(3065): [client 127.0.0.1] r->uri = /test.example.com/test.example.com/test.example.com/test.example.com/test.example.com/test.example.com/test.example.com/test.example.com/test.example.com/test.example.com/
[Thu Jul 21 19:41:33 2011] [debug] core.c(3071): [client 127.0.0.1] redirected from r->uri = /test.example.com/test.example.com/test.example.com/test.example.com/test.example.com/test.example.com/test.example.com/test.example.com/test.example.com/
[Thu Jul 21 19:41:33 2011] [debug] core.c(3071): [client 127.0.0.1] redirected from r->uri = /test.example.com/test.example.com/test.example.com/test.example.com/test.example.com/test.example.com/test.example.com/test.example.com/
[Thu Jul 21 19:41:33 2011] [debug] core.c(3071): [client 127.0.0.1] redirected from r->uri = /test.example.com/test.example.com/test.example.com/test.example.com/test.example.com/test.example.com/test.example.com/
[Thu Jul 21 19:41:33 2011] [debug] core.c(3071): [client 127.0.0.1] redirected from r->uri = /test.example.com/test.example.com/test.example.com/test.example.com/test.example.com/test.example.com/
[Thu Jul 21 19:41:33 2011] [debug] core.c(3071): [client 127.0.0.1] redirected from r->uri = /test.example.com/test.example.com/test.example.com/test.example.com/test.example.com/
[Thu Jul 21 19:41:33 2011] [debug] core.c(3071): [client 127.0.0.1] redirected from r->uri = /test.example.com/test.example.com/test.example.com/test.example.com/
[Thu Jul 21 19:41:33 2011] [debug] core.c(3071): [client 127.0.0.1] redirected from r->uri = /test.example.com/test.example.com/test.example.com/
[Thu Jul 21 19:41:33 2011] [debug] core.c(3071): [client 127.0.0.1] redirected from r->uri = /test.example.com/test.example.com/
[Thu Jul 21 19:41:33 2011] [debug] core.c(3071): [client 127.0.0.1] redirected from r->uri = /test.example.com/
[Thu Jul 21 19:41:33 2011] [debug] core.c(3071): [client 127.0.0.1] redirected from r->uri = /

求助

------解决方案--------------------
首先你要确定站点目录支持RewriteRule
因为这个在主配置那边是可以限制的:Allowoverride None
还有下面的修改下:
RewriteRule ^(.*)$ /%{SERVER_NAME}/$1 [L]
------解决方案--------------------
apache配置就行了

使用这个VirtualDocumentRoot /example.com/%0

用DocumentRoot是不行的