On pages that has no trailing slashes in their URL, is there any way to use relative links that will keep the page in the url?
For example, the link
a href="content"
on the page
http://www.domain.com/page/
will link to:
http://www.domain.com/page/content
But the same link on the page: (notice the missing slash)
http://www.domain.com/page
will link to:
http://www.domain.com/content
Since my website has no trailing slash (second example), I can't use relative links and must use the full path (a href="/page/content").
Other than including a trailing slash in the link in the first place, or redirecting from paths missing a trailing slash, you may also set the base tag such that it always includes a trailing slash and the current path.
<head>
<base href="/page/" target="_self">
</head>
Then relative links should work as anticipated as long as the browser supports this. It is also possible to fully qualify the path. You may not be able to set this dynamically with javascript.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With