views:

135

answers:

2

Just started a site and I have an /img directory on the main domain. I would like to set up a subdomain(where the file folder is just another one in the main directory) that is able to use the /img folder, but it doesn't work.

The /img and /subdomain folders are on the same level, so to display images in the main domain I type: <img src="img/image.jpg"> and for the /subdomain I type: <img src="../img/image.jpg"> and I get a 404 error for the site: http://subdomain.example.com/img/image.jpg As you can see, I want it to be linking to http://www.example.com/img/image.jpg

Can anyone tell me how to achieve this? I would prefer not to link images to their internet directory (i.e. http://www...) because I would like to modify the sites on my computer and upload them via ftp to my site hosted by bluehost.com.

I'm sure it's just something that I am messing up or don't completely understand. Thanks in advance!

+1  A: 

In your folder structure on your web server, create a symbolic link /subdomain/img pointing to the target /img.

In linux, this can be done by:

cd /your_web_folder/subdomain
ln /your_web_folder/img img -s
Fragsworth
how can this be done in simple html though? or css?
ServAce85
ServAce85: It cannot. You will have to modify something on your server.
Fragsworth
gotcha. yeah, that's what i figured about 3 seconds after i pressed "add comment"thanks Fragsworth for the help.
ServAce85
A: 

Do not use subdomains for asset management. From an enterprise perspective you will end up with hundreds of subdomains and have no idea what each represents. I know this must sound absurd, but I have seen it happen.

I would strongly recommend using a well thought out directory structure that balances asset types against versioning information. I would also recommend using a content distribution system, such as the edgesuite networks.

could you be a little more specific as to what you're talking about, please. I'm somewhat new to hosting sites and don't completely get what you're talking about. thx.
ServAce85
I am just saying that using subdomains as a means of managing site assets is a bad idea that typically becomes a slippy slope of management failure. Let me know what questions you have specifically.