I want to write URL that work regardless whether the base URL is either of:
E.g.
<a href="other.html">Other</a>
Should go to
respectively,
But instead in both cases they go to:
This is not a problem if the base URLs are
Any ideas?
I want to write URL that work regardless whether the base URL is either of:
E.g.
<a href="other.html">Other</a>
Should go to
respectively,
But instead in both cases they go to:
This is not a problem if the base URLs are
Any ideas?
If you give exactly like
<a href="other.html">Other</a>
it is a relative address and it should work like that.
Remember that when you are linking to a file:
www.example.com/folder/other.html
from:
www.example.com/index.html
you must give the link in index.html as:
<a href="folder/other.html">Other</a>
That is, you have to link to the file using the relative address.
Relative URIs are always resolved from the base URI which is the URI of the document if not explicitly declared otherwise (see the base
element). So what is the base URI in your case?
I suspect you were testing this with a base url of:
(no trailing slash)
If there is no slash, the browser will think "myfolder" is just a file and not a folder. So click a relative url will not go into that folder.
If the base url is this, then it should work as you expect.
Usually, I prefer absolute URLs just to avoid these headaches. Just about every link in my webapps is in the style:
/myfolder/other.html
Which always points to the same place from any location.