且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

页面上的相对链接,不带斜杠

更新时间:2023-12-03 09:15:10

除了首先在链接中包含尾部斜杠,或者从缺少尾部斜杠的路径重定向之外,还可以将基本标记设置为始终包含尾部斜杠和当前路径.

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>

然后,只要浏览器支持,相对链接应该可以正常工作.也有可能完全限定路径.您可能无法使用javascript动态设置.

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.