Apache重写.png文件

Apache重写.png文件,apache,mod-rewrite,Apache,Mod Rewrite,我正在使用一个由多个租户访问的系统 理想情况下,我需要为不同的客户显示不同的logo.png文件 为了保持使用单个站点,我想使用Virtualhosts和ServerName函数来识别哪个客户端连接,然后将默认徽标文件重写为更具体的文件 i、 e当使用customer1.example.com连接时,您将获得customerlogo1.png,但当连接到customer2.example.com时,您将获得customerlogo2.png。我试过下面的方法,但不起作用 有人能帮忙吗?非常感谢

我正在使用一个由多个租户访问的系统

理想情况下,我需要为不同的客户显示不同的logo.png文件

为了保持使用单个站点,我想使用Virtualhosts和ServerName函数来识别哪个客户端连接,然后将默认徽标文件重写为更具体的文件

i、 e当使用customer1.example.com连接时,您将获得customerlogo1.png,但当连接到customer2.example.com时,您将获得customerlogo2.png。我试过下面的方法,但不起作用

有人能帮忙吗?非常感谢

<VirtualHost *:80>
ServerName customer1.example.com
DocumentRoot /usr/share/customers/www
RewriteEngine On
Options +FollowSymLinks
RewriteRule ^customerlogo1.png$ customerlogo2.png
</VirtualHost>

<VirtualHost *:80>
ServerName customer2.example.com
DocumentRoot /usr/share/customers/www
</VirtualHost>

ServerName customer1.example.com
DocumentRoot/usr/share/customers/www
重新启动发动机
选项+FollowSymLinks
重写规则^customerlogo1.png$customerlogo2.png
ServerName customer2.example.com
DocumentRoot/usr/share/customers/www

如果我理解你的意思,你会这么做吗

<VirtualHost *:80>
ServerName customer1.example.com
DocumentRoot /usr/share/customers/www
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^customerlogo\.png$ customerlogo1.png [L]
</VirtualHost>

<VirtualHost *:80>
ServerName customer2.example.com
DocumentRoot /usr/share/customers/www
RewriteEngine On
RewriteRule ^customerlogo\.png$ customerlogo2.png [L]
</VirtualHost>

ServerName customer1.example.com
DocumentRoot/usr/share/customers/www
选项+FollowSymLinks
重新启动发动机
重写规则^customerlogo\.png$customerlogo1.png[L]
ServerName customer2.example.com
DocumentRoot/usr/share/customers/www
重新启动发动机
重写规则^customerlogo\.png$customerlogo2.png[L]

在HTML文档中,您使用的是相同的通用customerlogo.png。

由于这些域来自不同的目录(
/usr/share/customer1/www
/usr/share/customer2/www
),您不能只向每个域上载不同的图像吗?是的,对不起。实际站点是相同的。代码更正。哦,好的:-)我认为在语句中,必须在匹配字符串中包含初始正斜杠。看看这是否有效:
RewriteRule^/customerlogo1.png$/customerlogo2.png
。运气不好。还有其他想法吗?谢谢你的回复。试过了,运气不好。这两个网站仍然得到默认的标志。有没有办法检查重写是否有效?模块已启用,但只是想知道该配置是否正常,是否可能是其他配置?