[英]How to remove an anchor in a url with IIS rewrite module?
我有这个网址https://example.com/test/#/anchorpart1/anchorpart2 ,我想重定向到https://example.com/test2 。
到目前为止,我创建了以下规则:
<rule name="Redirect" stopProcessing="true">
<match url=".*" />
<action type="Redirect" url="https://example.com/test2" appendQueryString="false" redirectType="Permanent" />
</rule>
这将导致以下结果:
https://example.com/test2#/anchorpart1/anchorpart2
如何通过使用匹配或条件规则将“#/ anchorpart1 / anchorpart2”删除为仅具有“ https://example.com/test2 ”?
URL(#片段)之后的部分从未按照HTTP规范传递到服务器,因此,URL重写将看不到它。
要解决此问题,您可以部署一个静态HTML页面,该页面将用于重定向请求,例如下面的示例:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0;url=https://example.com/test2">
</head>
<body>
<script language="javascript">
window.location.href = "https://example.com/test2"
</script>
</body>
</html>
通过使用以下解决方案,您将能够转义传入请求URL的#(片段)并将其重定向。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.