我试图在 web.config 文件中创建一个以“#”字符开头的重写规则。
我有以下网址“www.example.com/#abcd= http://www.example.com/myfolder/mypage ”。此 URL 需要重定向到“www.example.com/myfolder/mypage.html”。
我已经尝试了以下规则,但似乎没有一个有效。
<rule name="myRedirect" stopProcessing="true" patternSyntax="ExactMatch" >
<match url="##abcd=http://www.example.com/myfolder/mypage" ignoreCase="false"/>
<action type="Redirect" url="myfolder/mypage.html" appendQueryString="true" redirectType="Permanent" />
</rule>
和以下
<rule name="myNewRedirect" stopProcessing="true">
<match url="(.*)"/>
<conditions>
<add input="{QUERY_STRING}" pattern="cbp=http://www.example.com/myfolder/mypage" />
</conditions>
<action type="Redirect" url="/myfolder/mypage.html" redirectType="SeeOther"/>
</rule>
但以上都没有奏效。
无法根据哈希字符串进行重定向。浏览器不会将该部分(哈希后的所有内容)传输到服务器。
它称为片段标识符,仅用于客户端。除非您使用某些浏览器实现(或软件)将 URL 的那部分发送到服务器,否则在任何语言中都是不可能的。参考:http : //en.wikipedia.org/wiki/Fragment_identifier
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句