https://our.app.com/customer-one
和https://our.app.com/customer-two
。目前,我们能够使用document.location
动态设置<base href...>
。因此,当用户访问https://our.app.com/customer-two
时,<base href...>
会被设置为/customer-two
......完美!问题是,如果用户在例如
https://our.app.com/customer-two/another-page
处,并刷新页面或尝试直接访问该网址,则<base href...>
会被设置为/customer-two/another-page
,并且资源无法找到。我们尝试了以下方法,但均无效:
<!doctype html>
<html>
<head>
<script type='text/javascript'>
var base = document.location.pathname.split('/')[1];
document.write('<base href="/' + base + '" />');
</script>
...
很遗憾,我们已经没有更多的想法了。任何帮助都将是惊人的。