Search code examples
htmlhyperlinkhrefradix

How to change the root for links in html


I was hoping that adding a <base href="http://www.myweb.com/newroot/" /> tag would cause that links like /link would point to http://www.myweb.com/newroot/link instead of http://www.myweb.com/link.

Soon I realized it does not work that way and it only applies to hrefs which do not start with /.

But is there any way to achieve the behavior I expected before (without the use of JavaScript)?


Solution

  • links with a leading / always point to the root/domain. This is a client-side issue, i think there is no other solution than dropping the / of using js.