Confused About Relative Url Anchor Tag

- 1 answer

I'm confused about relative href url in anchor tag. I have a case below:

I have a homepage that can be accessed with or with return the same page. In that page I have anchor tag with relative url href='./about' (I can not use absolute or root-relative url in this case). The problem is:

  • When I access the page through url then click the anchor link, it will redirect to (this is my expected result).

  • But if I access the page through then click the link, it
    will redirect to (this is not my expectation).

Anyone please give me a solution for this. Thank you all.



The solution is to add a trailing slash to your base URL, i.e.

Here is the relevant line from the specification of relative URLs (RFC 1808)

The last segment of the base URL's path (anything following the rightmost slash "/", or the entire path if no slash is present) is removed and the embedded URL's path is appended in its place.

I would also suggest adding a redirect from to