使用通配符dns / apache / mod-rewrite,我想实现以下function:
clientname.clients.company.com – > /home/company.com/clients/clientname
我试过重写规则,比如:
RewriteEngine On RewriteCond %{HTTP_HOST} ^([^\.]+)\.clients\.company\.com RewriteCond /home/clients\.company\.com/%1 -d RewriteRule ^(.*) /%1/$1 [L]
他们都没有似乎与* .clients.company.com模型 – 我得到一个无限循环错误。
它看起来像你基本上试图build立dynamicconfiguration的大容量虚拟主机 。 更简单的configuration是使用mod_vhost_alias 。 %1replace将包含主机名的第一部分,因此以下内容将适当地设置文档根目录。
UseCanonicalName Off VirtualDocumentRoot /home/company.com/clients/%1
(你实际上可以避免使用/home/%3-/%2/%1对大部分path进行硬编码。)