htmlbase-tag

How to link to website base ("home page") when base tag is present?


I have the following tag inside the head of my document:

<base href="/some/folder/">.

Let's say my website is at http://example.com. A link, like this:

<a href="foo/bar/">...</a>

on the page will resolve to http://example.com/some/folder/foo/bar/.

However, a link like this:

<a href="/">...</a>

will resolve to http://example.com when I actually want it to point to http://example.com/some/folder/.

In this situation, how can I create a link to the base of my application without hardcoding http://example.com anywhere?


Solution

  • Try <a href="./">...</a> instead of <a href="/">...</a>. As pointed out by cbroe