我正在寻找一种解决方案,以为子域名所确定的服务器上的变化路径创建别名。文件夹在文档根目录后面的位置。
如何使http://*.site.com/images/
指向/var/www/site/clients/*/images/
?
类似的东西:
Alias /images "/var/www/site/clients/$(var)/images/"
(请注意,我不打算将文档根目录更改为/ var / www / site / clients /*/。)
<VirtualHost *.domain.tld:80>
ServerName *.domain.tld
DocumentRoot "/var/www/site/public_html"
<Directory "/var/www/site/public_html">
Options -Indexes
DirectoryIndex index.php index.html
AllowOverride All
</Directory>
Alias /images "/var/www/site/clients/*/images"
</VirtualHost>
尝试#1-失败404:
RewriteCond %{HTTP_HOST} ^([^.]+)\.
RewriteRule ^/images/(.*)$ /var/www/site/clients/%1/images/$1 [L]
尝试#2-失败404:
SetEnvIf Host "^([^.]+)\." SUBDOMAIN=$1
Aliash /images /var/www/site/clients/%{env:SUBDOMAIN}/images