2017-08-30 49 views
1

我正尝试在以“#”字符开头的web.config文件中创建重写规则。如何创建以'#'开头的重写规则

我有以下URL“www.example.com/#abcd= http://www.example.com/myfolder/mypage”。该网址需要重定向到“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> 

但没有上述的正常工作。

回答

1

基于散列字符串不可能做重定向。浏览器不会将该部分(哈希后的所有内容)传输到服务器。

它被称为片段标识符,只是客户端。除非您使用某些浏览器实现(或软件)将URL的一部分发送到服务器,否则无法使用任何语言。参考:http://en.wikipedia.org/wiki/Fragment_identifier