假设我的页面 URL 是:http://example.com/path/to/dir/index.html
我通过以下方式代理此页面:http://proxyserver.com/path/to/dir/index.html。同样,我希望页面中的所有相对 URL 都由proxyserver.com而不是example.com. 什么应该是正确的<base>href 值?
我想要页面上的相对 URL,例如
newfile.html解决http://proxyserver.com/path/to/dir/newfile.html/newfile.html解决http://proxyserver.com/newfile.html#hash解决http://proxyserver.com/path/to/dir/file.html#hash
在页面中设置<base href="" />正确地完成了这项工作,但它有一些含义吗?跨浏览器是否有不同的解释?空href值实际上是什么意思?它适用于所有框架,如 Angular 吗?
我听说<base>标签对于 Angular 应用程序初始化是强制性的,因此删除<base>标签可能不起作用。
注意:该网站可能已经包含一些<base>我总是想覆盖的标签。
我也尝试过<base href="/" />,但它会解析相对 URL
newfile.html到http://proxyserver.com/newfile.html和#hash这http://proxyserver.com/#hash是错误的。
非常感谢任何帮助。