简体   繁体   English

IIS 重写 - 如何从 url 中过滤和删除#attribute

[英]IIS-Rewrite - How to filter and remove #attribute from the url

I am writing the redirect rule for redirecting the old domain url http://old.domain.com/promotions#all-views to http://new.domain.com/en-us/promotions/all我正在编写重定向规则,用于将旧域 url http://old.domain.com/promotions#all-views重定向到httpen/all-views

I have tried multiple options but could achieve the above redirection, here mentioned the sample rule used for this,我尝试了多个选项,但可以实现上述重定向,这里提到了用于此的示例规则,

<rule name="Redirection for promotions" stopProcessing="true">
    <match url="^promotions$" />
    <conditions>
      <!--  <add input="{QUERY_STRING}" pattern="all-views" /> -->
      <!--  <add input="{REQUEST_URI}" pattern="#all-views$" /> -->      
    </conditions>
    <action type="Redirect" url="http://new.domain.com/en-us/promotions/all" appendQueryString="false" />
</rule> 

Issue 1: Couldn't match the url pattern "#all-views", server variables are not providing this data, I have validated with HTTP_URL, REQUEST_URI, URI, QUERY_STRING问题 1:无法匹配 url 模式“#all-views”,服务器变量未提供此数据,我已使用 HTTP_URL、REQUEST_URI、URI、QUERY_STRING 进行了验证

Issue 2: "#all-views" always appended with the redirected url like, http://new.domain.com/en-us/promotions/all#all-views , how to remove the #all-views?问题 2:“#all-views”始终附加重定向的 url,例如http://new.domain.com/en-us/promotions/all#all-views ,如何删除 #all-views?

You can try the rule below:你可以试试下面的规则:

<rule name="test1" enabled="false" stopProcessing="true">
   <match url="^(.*)$" />
       <conditions>
          <add input="{HTTP_HOST}" pattern="^old.domain.com$" />
       </conditions>
   <action type="Redirect" url="http://new.domain.com/en-us/promotions/all" />
</rule>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM