Search code examples
htmlhref

href to subdirectory of current url


Assume the current url is : www.my.com/somewhere.

And I have a href link and want it go to : www.my.com/somewhere/subpage without writing current url(www.my.com/somewhere) in href.

Is it possible in pure HTML (not by javascript or server-side things)?


Solution

  • 2020 - current state of this question:

    if the current URL is this www.my.com/somewhere The shorthand ./subpage or just subpage will navigate to www.my.com/subpage

    If the current URL ends in a /, then it will navigate as question is asking.

    www.my.com/somewhere is not the same as www.my.com/somewhere/

    So how to navigate to subpage from www.my.com/somewhere? use: somewhere/subpage