2013-12-23 84 views
1

我正嘗試使用重寫規則將特定頁面重定向到另一個頁面。但是,當我在web配置中添加下面的代碼時,我得到500內部服務器錯誤。301重寫/重定向規則導致500內部服務器錯誤

<rewrite> 
     <rules> 
     <clear /> 
     <rule name="New Rewrite" enabled="true"> 
      <rule name="Redirect" stopProcessing="true"> 
      <match url="http://www.mydomain.com/terms" /> 
      <action type="Redirect" url="http://www.mydomain.com/" redirectType="Permanent"/> 
      </rule> 
     </rule> 
     </rules> 
    </rewrite> 

我不知道很多關於重定向,但我做的是,讓我們說我有一個域www.mydomain.com,如果我有一個特定的URL www.mydomain.com/terms我需要它重定向到家庭,這是www.mydomain.com

UPDATE

我已經改變了重寫規則給出,依然能夠訪問頁面條款。第一部分添加www到非基於www的url可以正常工作,但不知道第二條規則中的錯誤。

<rewrite> 
     <rules>   
     <rule name="WWW Rewrite" enabled="true"> 
      <match url="(.*)" /> 
      <conditions> 
      <add input="{HTTP_HOST}" negate="true" pattern="^www\." /> 
      </conditions> 
      <action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent" /> 
     </rule> 
    <rule name="news redirect" stopProcessing="true"> 
      <match url="/terms" ignoreCase="true"/> 
      <conditions> 
      <add input="{HTTP_HOST}" pattern="domain\.com$" /> 
      </conditions> 
      <action type="Redirect" url="http://www.mydomain.com/{R:1}" /> 
     </rule> 
     </rules> 
    </rewrite> 

回答

1

嘗試從比賽URL刪除主機:

<match url="/terms" /> 
+0

親愛的夫君,我編這個樣子,還是同樣的錯誤 ' <規則名稱= 「301重定向1」 stopProcessing =」真 「> <匹配URL =」/術語」 /> <動作類型= 「重定向」 URL = 「http://127.0.0.1:81/」 redirectType = 「常駐」/> ' – TBA

+0

@TBA你似乎也有嵌入對方的2條規則,擺脫''行和其中一條''行 –

+0

謝謝,我做到了。仍然沒有運氣 – TBA

相關問題