How does IIS URL Rewrite handle # anchor tags

狂风中的少年 提交于 2021-02-16 16:24:07

问题


I'm struggling to find any information on how best to handle URLs with anchor tags, like the #foo in www.example.com/index.html#foo

Our current situation is trying to use a Rewrite map for a URL with an anchor tag, but it is being trumped by another Rewrite mapping.

e.g.

 <add key="index.html#foo" value="bar1.html" />
 <add key="index.html" value="bar2.html" />

 <!-- A request to index.html#foo is being redirected to bar2.html, 
      not bar1.html as expected -->

Does URL Rewrite include this in the URL? Or is available via one of the variables? Is there documentation on this?

(I've also tried searching on "fragment identifier", "#" "hash" "hash tag")


回答1:


The portion of the URL after # (fragment) is never passed to the server as per HTTP spec, therefore, URL rewrite won't see it.

Source: Does IIS throw away the URL fragment on custom error pages?



来源:https://stackoverflow.com/questions/9422734/how-does-iis-url-rewrite-handle-anchor-tags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!