Making css image absolute paths goto the root of a

2019-07-02 03:40发布

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/client2/site developmentdomain.com/client/anothersite

Every things works fine (including furls) if i have a base ref in the html and add a RewriteBase rule my htaccess file.

But for some if within the css i have:

background: url("/assets/images/someImage.png");

Its trying to find the image at this location: developmentdomain.com/assets/images/someImage.png

When it needs to be looking at: developmentdomain.com/client1/site/assets/images/someImage.png

I'm guessing i need to do a rewrite rule in the htacess, but what?

Oh and this is what i have in the htacces file for my RewriteBase

RewriteEngine On
RewriteBase /client1/site

Any help much appreciated.

Thanks Ben

1条回答
Juvenile、少年°
2楼-- · 2019-07-02 04:09

No need for rewrite rules. You just need to use relative urls instead of root-relative. So use:

background: url("assets/images/someImage.png");

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)

查看更多
登录 后发表回答