多个docroot取决于第一个域名

时间:2012-09-19 14:15:10

标签: apache httpd.conf

Atm我们有一些重写规则,可以根据第一个域名查找resurces。 我们希望改进它,因此我们不必将基本模板文件复制到每个文件夹,然后将特定文件复制到特定文件夹。

规则是:

RewriteRule ^web([0-9]{1})\.localhost(.*)$ C:/dir/http/test/htdocs/$1$2 [L]

我们正在寻找改善它的方法。如果上面给出了404,那么我们想查看另一个位置,如:C:/ dir / http / test / htdocs / base / $ 2 如果这给了404那么就可以了。

我试图将RewriteCond放在前面而没有任何运气。

有人知道解决方案吗?

1 个答案:

答案 0 :(得分:1)

尝试:

RewiteCond %{REQUEST_FILENAME} !-f
RewiteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/web([0-9]{1})\.localhost(.*)$
RewriteCond C:/dir/http/test/htdocs/%1%2 -f
RewriteRule ^ C:/dir/http/test/htdocs/%1%2 [L]

RewiteCond %{REQUEST_FILENAME} !-f
RewiteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/web([0-9]{1})\.localhost(.*)$
RewriteCond C:/dir/http/test/htdocs/base/%2 -f
RewriteRule ^web([0-9]{1})\.localhost(.*)$ C:/dir/http/test/htdocs/base/$2 [L]
相关问题