tags:

views:

65

answers:

3

Okay, I feel totally stupid posting this. I am not sure if it is classified as a programming question, but its close enough. In my web application, one page uses relative links like this:

<img src='images/start.png' />

My other page is in exactly the same directory, but firebug says that the above code equals http://localhost/projectFolder/viewtrip.php/images/start.png. I am confused, and I feel like a total idiot. Is there something I am obviously doing wrong?

+1  A: 

Try:

<img src='./images/start.png' />
waqasahmed
that works, but why? I found out that the same thing was happening to my linked javascript and css files.
Dan
because your images are clearly not in a php file.
David
and if you have subdomains on your site you might want to have an image helper func that always does an absolute path to the images so that they don't get downloaded a 2nd time from a different subdomain (referring to browser cache here)
David
ya, but why did it work in the other file?
Dan
A: 

is there a base tag in the HTML somewhere?

like this? <base href="http://localhost/myfolder/viewtrip.php" />

(there shouldn't be it doesn't make sense but I can't think of something else)

p.s. where in firebug do you see this path?

olle
No base tag, and I see it when I open the image in a new tab (i guess that's not firebug, my mistake).
Dan
A: 

When you specify a relative path, you are saying the browser that that element is in that place using the current document as base. Where is the images directory in your website? If you put a / at the front of the path, you are saying the browser that the element can be found using the root from your website as base. The only real value I have found to use ./ or ../ in front of paths is to have a proper rendering on preview while editing the file and some times it causes trouble (for me) at release time.

Edmundo