Forum Moderators: open

Message Too Old, No Replies

Relative path problem with images - I can't go two directories deep?

         

Kysmiley

1:46 am on Dec 23, 2004 (gmt 0)

10+ Year Member



For some reason when trying to use a relative path my images can not be out of the main dir. I have page like www.example.com/dir/dir. For the index page and CSS part of the second dir, the images for the background have to go in the dir directory itself.

If i use ../inamename.gif it will work and show up. yet if i place it one down and use the /dir/image/imagename.gif dir like this ../images/imagename.gif it wont work.

The same is tru for my CSS file as an external file. How do i work with different layers of dir's.

Also for some reason my images would not show up using the full path like http://www.example.com/dir/images/imagename.gif

Any ideas why they would not show this way and will the short way? This is becoming frustrating - the images and css one layer from the main dir i have no problems with, yet soon as I move to a deaper layer they dont work

Pat

[edited by: tedster at 5:44 am (utc) on Dec. 23, 2004]
[edit reason] use example.com [/edit]

tedster

5:51 am on Dec 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If your page is two directories deep, and you want to use a relative URL to reference an image or css file relative to the site's root directory, then you need to use this syntax:

../../

to instruct the server to look "back" two directories. Does that address your problem?

Kysmiley

1:25 pm on Dec 23, 2004 (gmt 0)

10+ Year Member



Thank-you tedster, that does help. I did not know of doing the ../../ using the extra../ for the depth of the dir's I wasa trying anew .../ sort of for the extra levals. Learned somthing new again today thanks again
Pat