Jump to content

Images on subdomain?


wwfc_barmy_army

Recommended Posts

Hello.

 

Not really sure which section this belongs in but;

 

I have a domain and subdomain, lets say, mydomain.com and mysub.mydomain.com.

 

Mydomain.com has a fully working website, images in a folder called images. I want the same layout on my subdomain, I can link the css and the javascript using the file path, eg ../css/mycss.css, but obviously i can't do the same with the images because of the way the browser gets them and it looks in mysub.mydomain.com.

 

Instead of copying over the images folder, or giving it a full domain path in the image link (eg. <img src="http://mydomain.com/images/myimage.jpg">) is there a way of setting the image paths to default to the main domain directory? Htaccess maybe?

 

Thanks.

Link to comment
Share on other sites

To my knowledge a browser will always parse a URL in the same manner, regardless of whether it is a href attribute, src attribute or link attribute. If the css and javascript files work with this pattern I would have thought the same method would work with an image. Having said this I don't have a sub domain to test it with. I'm guessing it will depend greatly on how the sub domain is implemented.

Link to comment
Share on other sites

I personally think that Ignace had a good solution for a couple of reasons. The first is that it solves the problem, though it will involve a little more coding. The second is that because the images are on a separate domain (subdomains are considered separate from the main domain), cookies should not be sent along with the request for the images, meaning that it should increase download speeds for the site a little. And the last is that browsers will only request two items from a single domain at one time, but can request two items from each domain all at the same time. So if your images are coming from a separate domain to the rest of you elements, it should speed up download times as more items can download concurrently.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.