obenjiro
obenjiro

Reputation: 3750

Relative path URL problem

Ok. So the problem is here..

on this address i have this url: _http://localhost/blog

img src='image/b.jpg'

and everything goes fine.. because i have my image in "image" folder... browser asking image with this url "_http://localhost/image/b.jpg"

but if i got to: _http://locahost/blog/otherfolder/

then browser start looking for "_http://localhost/blog/image/b.jpg"

I know why this happen. But i only want to know is there a way to set "universal" relative url? That ignore folders and relative to host? By plain HTML

Something like ".. src='{host}/image/b.jpg' .."

Upvotes: 1

Views: 9826

Answers (3)

bouncingHippo
bouncingHippo

Reputation: 6040

done this way <img src='/image/b.jpg' />

Upvotes: 0

Adrian Smith
Adrian Smith

Reputation: 17553

Yeah this is a bit of broken-ness in the web. I mean I am writing JSP tags, and either

  • they write absolute URLs (which requires them to know a bit too much; our URLs are composed of a number of parts which those JSP tags wouldn't really need to know as they navigate only within one section.. i.e. the left part of the URL, beyond a certain point, is always constant... without wanting to bore you with the details..)
  • they write relative URLs which means they can only be used in one "level" of the URL structure (we have pages like /folder1/folder2/page3 etc and those tags can be used anywhere, so that won't work)

So we go with absolute URLs, but it's not ideal.

Not that, if I were designing the web, I would have a better way to do it ....

Upvotes: 0

Thilo
Thilo

Reputation: 262504

 <img src='/image/b.jpg' />

Upvotes: 8

Related Questions