2010-10-26 83 views
1

我收到了一个特殊请求。我用lighttpd evhost和一切正常,除了这个:多个文档根

$HTTP["host"] =~ "^[^.]+\.[^.]+$" { 
    evhost.path-pattern = vhosts_dir + "/customers/%2.%1/public/" 
    evhost.path-pattern = vhosts_dir + "/customershops/%2.%1/public/" 
    evhost.path-pattern = vhosts_dir + "/company/%2.%1/public/" 
} 

所以我想使我的模式上面的目录是“动态”。或者实际上只是查看三个目录,然后使用正确的vhost目录。

问候

反叛先生

回答

0

mod_evhost必须能够从提交主机的部件找出一个文档根目录。它不能猜测三种选择,也不能试图找出哪一种存在(尤其是如果多于一种不经意地这样做)。

您将不得不在主机名中给mod_evhost足够的信息来明确地选出一条路径,否则您将不得不在文件系统中至少进行一级重定向。

选项1:

evhost.path-pattern = vhosts_dir + "/%2.%1/public/"
这会丢失您想要捕获的所有客户/商店/公司信息,但实际上它使mod_evhost可以工作。

选项2:您可以根据需要拆分目录,指向一个包含指向这些目录的链接的目录。 FS具有可见的结构,mod_evhost只需猜测重定向到结构中的链接的名称即可。

 
    directory_containing_links/ 
    foo.bar -> ./customers/foo.bar/public/ 
    foo.baz -> ./customershops/foo.baz/public/ 
    foo.qux -> ./company/foo.qux/public/ 
    quux.bar -> ./customershops/quux.bar/public/ 
    quux.baz -> ./customers/quux.baz/public/ 
    (and so on, with one link per site) 
    directory_containing_sites/ 
    company/foo.qux/public/(web site here) 
    customers/foo.bar/public/(web site here) 
    customers/quux.baz/public/(web site here) 
    customershops/foo.baz/public/(web site here) 
    customershops/quux.bar/public/(web site here) 
然后你的evhost模式是
evhost.path-pattern = directory_containing_links + "/%2.%1/"
请注意,directory_containing_links和directory_containing_sites可以是同一个目录。

+0

选项2看起来很有趣。要检查出来。我在其他服务器上使用选项1,它的功能就像一个魅力。 – 2010-10-27 06:44:42

+0

非常感谢Eric – 2010-10-27 06:45:21