簡體   English   中英

301重定向在IIS 7中不起作用

[英]301 redirect not working in IIS 7

我需要創建此301重定向規則: /blog/item.asp?n=12817重定向到/blog/item/12817

我在IIS URL重寫模塊中使用以下參數創建了一個規則:

模式: ^blog/item.asp\\?n=([0-9]+)

重定向網址: blog/item/{R:1}

當我在IIS中對其進行測試時,它工作正常,並在我的web.config中創建了以下規則:

<rule name="Asp classic Legacy 301 redirect" stopProcessing="true">
   <match url="^blog/item.asp\?n=([0-9]+)" />
   <action type="Redirect" url="blog/item/{R:1}" appendQueryString="true" />
</rule>

但是,當我在瀏覽器中導航到/blog/item.asp?n=12817 ,仍然顯示The resource cannot be found. 文本Requested URL: /blog/item.asp錯誤Requested URL: /blog/item.asp

為什么會這樣呢? 我需要在其他地方切換其他東西嗎?

謝謝

好的,我創建了另一個有效的規則:

<rule name="Asp classic legacy 301 redirect">  
  <match url="blog/item\.asp$" />  
    <conditions>  
      <add input="{QUERY_STRING}" pattern="n=(\d+)" />  
    </conditions>  
    <action type="Redirect" url="blog/item/{C:1}" redirectType="Permanent" appendQueryString="false"/>  
</rule> 

仍然想知道為什么Url重寫模塊會生成不起作用的規則?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM