How to share images between subdomains?


Tags: php,css,css3,subdomains

Problem :

I have a domain, lets call it 'oficial' and a subdomain.

This subdomain is a copy from oficial in design terms speaking (CSS, images, etc)

My problem is how to use all the images and styles from oficial domain ?

I tried to include CSS files into subdomain like this include(/var/www/oficial/styles/style.css); It worked but all the classes with background-image property didn't work because they are declared like this:

background:url(../images/image.jpg);

so, it is trying to reach images folder into the subdomain directory, and there is the real problem.

I thought to put full URL instead, but I would have to modify all CSS files with background-image property

Is there any other way to achieve this ?

Thanks in advance!



Solution :

Don't load the stylesheet inline.

You can link to style sheets externally like this:

<link rel="stylesheet" type="text/css" href="http://www.mystyle.css">

That way, the background images will be relative to where the stylesheet is hosted and not the page where it is embedded.


    CSS Howto..

    How to make first letter lowercase in span with css?

    hover div to show another div

    How can I make sure that the footer will always be on the bottom of the last page when printing out?

    How to Highlight a list item after user clicks on link

    CSS: How to center element that is bigger then the container?

    How to put a border on a triangle shape using css?

    how to apply ellipse effect in which contain space in string?

    How to find the proper offsets for CSS sprites?

    How to draw a Normal Distribution Curve (Bell curve) using CSS and JavaScript?

    How to make left menus height dynamic

    How to reduce my code in both jQuery and CSS

    How do I keep multiple DIVs the same height using jQuery?

    How do I make elements flow horizontally instead of vertically?

    How to make a scrolling row of Divs using CSS & Javascript?

    How can i scroll to specific ID using Header?

    Polymer 1.0 how can I style a paper-input:disabled?

    Picture doesn't show up [closed]

    How can I invoke an “AktionLink” in an “onClick” event in a “div”?

    How to expand wrapper when content is more?(with CSS)

    How to make “button-like appearance” with CSS

    how to stretch an image in background css property

    How to draw a specific shape in CSS? [closed]

    How to avoid an unknown height sticky footer to overlap content with CSS only?

    How can I resize to fit html elements horizontally using CSS?

    2nd image appears as mirror image in IE— CSS image FLIP transform- How to fix?

    How to display fieldset text and button inline on small screens?

    how to add line break in HTML using jQuery

    How to remove dotted border around active hyperlinks in IE8 with CSS

    How to get all blue background divs to align to the left and get all the red divs to align to the right using the css float property?

    how to prevent shifting when changing border width