2

I have always thought a relative URL was relative to the URL in the browser address bar. But today my beliefs were shaken.

In a webpage that has the URL https://localhost:44372/docs/morpher.ru/ws/3/russian/declension/GET I put an href which looks like this:

<a href="../../../response-format/index.md">выбор формата ответа</a>

When I click the link, the browser takes me to

https://localhost:44372/response-format/index.md

Whereas I would expect to be taken to

https://localhost:44372/docs/morpher.ru/ws/response-format/index.md

Are my expectations incorrect? What is the relative path really relative to?

enter image description here

Sergey Slepov
  • 1,861
  • 13
  • 33
  • https://jsbin.com/ducabicegi/1/edit?js,console — your expectation is correct. Maybe you missed a redirect response somewhere. – Quentin Sep 06 '20 at 22:47
  • https://stackoverflow.com/questions/2005079/absolute-vs-relative-urls may be this will help you – Imran Mohammed Sep 06 '20 at 22:49

1 Answers1

2

It's likely the case that there is a <base> tag.

You can change the relative path base like so:

<base href="https://example.com/new-base" />

Then, everything is relative to this, rather than what the page URL is.

Brad
  • 159,648
  • 54
  • 349
  • 530