问题
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