[eluser]John_Betong[/eluser]
[quote author="Optimus Prime" date="1190890903"]Hi, I hope that you can help me with this topic.
How to set a background image url in CSS when my CI applications is into a subfolder?
I explain my question:
(1) I am using two subfolder in my localhost. Because I'm developing two web application in the same PC. My directory tree is like this:
/ <--- www root
+--/site1
| +--/ci_folder
| | +--/application
| | +-- .... (all CI folders)....
| | ...
| +--/media
| +--/css
| +--/images
|
+--/site2
+--/ci_folder
| +--/application
| +-- .... (all CI folders)....
| ...
+--/media
+--/css
+--/images
(2) Well, the problem is the use of url inside of css file. I want to use "background-image: url(...)" propierty. It worked if I set: background-image: url(/site1/media/images/some_image.jpg)...
But it doesn't load when I set like this: url(/media/images/some_image.jpg). I tried to put "../media..." or "../../media..." but didn't work.
I think that is logical because the file does not exist in (root)/media/images directory, but I will copy all directory in another server (per example the site1 directory) and it'll convert in a root directory and I want to avoid to rewrite all url in the css files when I test the applications in another server.
So, there is a way to solve this problem?
.. Or maybe it is not possible to avoid to manually rewrite the url's in the css files, but I hope to confirm it or find a solution with your help for working with multiple sites (stored in differents subfolders) and CSS files.[/quote]
Hi Optimus Prime,
You could try:
Code:
1. introduce a "/common" folder, copy the common image and use
"background-image: url(/common/some_image.jpg)"
2. in your site2 CSS file:
background-image: url(/site1/media/images/some_image.jpg)
I use the first method and it works fine.
Also check to ensure that the path and image file are correctly case-sensitised if that is the correct wording?
Cheers,
John_Betong