问题
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:
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)
来源:https://stackoverflow.com/questions/8357526/making-css-image-absolute-paths-goto-the-root-of-a-sub-directory-not-the-root-o