问题描述
我有多个站点的设置在一个单一的开发领域的客户。因此,结构是这样的:
I have multiple sites for clients set up on a single development domain. So the structure looks like this:
developmentdomain.com/client1/site
developmentdomain.com/client1/site
developmentdomain.com/client2/sitedevelopmentdomain.com/client/anothersite
developmentdomain.com/client2/sitedevelopmentdomain.com/client/anothersite
每个事情能正常工作(包括卷起)如果我有在html基地ref和添加的RewriteBase治我的htaccess文件。
Every things works fine (including furls) if i have a base ref in the html and add a RewriteBase rule my htaccess file.
但对于一些如CSS,我有内:
But for some if within the css i have:
background: url("/assets/images/someImage.png");
它试图找到图像在此位置:developmentdomain.com/assets/images/someImage.png
Its trying to find the image at this location:developmentdomain.com/assets/images/someImage.png
当需要将其看:developmentdomain.com/client1/site/assets/images/someImage.png
When it needs to be looking at:developmentdomain.com/client1/site/assets/images/someImage.png
我猜我需要做的htacess重写规则,但什么?
I'm guessing i need to do a rewrite rule in the htacess, but what?
呵呵,这是我在htacces文件我的RewriteBase
Oh and this is what i have in the htacces file for my RewriteBase
RewriteEngine On
RewriteBase /client1/site
任何帮助非常AP preciated。
Any help much appreciated.
谢谢本
推荐答案
无需重写规则。你只需要使用相对URL,而不是根目录相对。因此,使用:
No need for rewrite rules. You just need to use relative urls instead of root-relative. So use:
background: url("assets/images/someImage.png");
或背景:网址(/图片/ someImage.png);
如果CSS位于资产的文件夹中。 (您可以使用 ../
如果需要上一个文件夹)
or background: url("/images/someImage.png");
if the css is located in the assets folder. (You could use ../
to go up one folder if needed)
这篇关于使CSS图像的绝对路径GOTO子目录的根目录,主要不是域的根的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!