2011-11-03 225 views
2

客戶的網站內容位於其網站上的子文件夾中,例如, www.customersite.com/content。它已經被移動到根文件夾,例如www.customersite.comIIS 301從子文件夾重定向到根文件夾

我們增加了IIS 301重定向到該網站的配置看起來像這樣:

<rewrite> 
    <rules> 
    <rule name="Redirect to Root" stopProcessing="true"> 
    <match url=".*" /> 
     <conditions> 
     <add input="{HTTP_HOST}" pattern="^customersite.com/content/$" /> 
     </conditions> 
     <action type="Redirect" url="http://www.customersite.com/{R:0}" 
     redirectType="Permanent" /> 
    </rule> 
    </rules> 
</rewrite> 

該網站有一個看起來像www.customersite.com/content/鏈接?如果用戶輸入舊的www.customersite.com/content/?p=12地址,p = 12是否可以將重定向改爲自動重定向到www.customersite.com/?p=12?如果是這樣如何?

謝謝!

回答

3

我不能馬上進行測試,但這應該工作:

<rewrite> 
    <rules> 
    <rule name="Redirect to Root" stopProcessing="true"> 
    <match url="^content/(.*)" /> 
     <conditions> 
     <add input="{HTTP_HOST}" pattern="^(www\.)?customersite.com$" /> 
     </conditions> 
     <action type="Redirect" url="http://{C:0}/{R:1}" redirectType="Permanent" /> 
    </rule> 
    </rules> 
</rewrite> 
0

www.customersite.com/content/?p=12的任何文件實際上都是IIS中的默認頁面之一,因此該頁面實際上類似於www.customersite.com/content/index.aspx假設你的默認文件是index.aspx,它可以是默認值等。

只需在此位置添加一個文件,並將代碼設置爲採取查詢字符串並進行重定向,您也可以更改標題從代碼狀態背後,顯示這是一個301