2014-03-31 202 views
0

我試圖重寫URL,例如用查詢字符串重寫:URL使用IIS URL重寫模塊

new_membership?R=1&I=2 

到:

agent_new_membership.aspx?R=1&I=2 

但我得到一個錯誤讀數:「HTTP錯誤404.0 - 未找到」

這是我使用的web.config文件代碼:

<rewrite> 
    <rewriteMaps> 
    <rewriteMap name="Redirects"> 
     <add key="/administration" value="/administration_main.aspx" /> 
     <add key="/change_admin_password" value="/admin_change_password.aspx" /> 
    </rewriteMap> 
    </rewriteMaps> 

    <rules> 
    <rule name="New Membership" stopProcessing="true"> 
     <match url="^new_membership?R=(\d+)&amp;I=(\d+)$" /> 
     <conditions> 
     <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
     <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
     </conditions> 
     <action type="Rewrite" url="agent_new_membership.aspx?R={R:1}&amp;I={R:2}" /> 
    </rule> 

    <rule name="Redirect rule1 for Redirects"> 
     <match url=".*" /> 
     <conditions> 
     <add input="{Redirects:{REQUEST_URI}}" pattern="(.+)" /> 
     </conditions> 
     <action type="Rewrite" url="{C:1}" appendQueryString="false" /> 
    </rule>   
    </rules> 

</rewrite> 

我在做什麼錯?

在此先感謝。

回答

0

這應該爲你工作:

<rule name="TestRule" stopProcessing="true"> 
     <match url="^new_membership\?R=(\d+)&amp;I=(\d+)$" /> 
     <conditions> 
     <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
     <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
     </conditions> 
     <action type="Rewrite" url="agent_new_membership.aspx?R={R:1}&amp;I={R:2}" /> 
    </rule> 
+0

仍然得到同樣的錯誤。我已根據您的建議更新了原文,以包含完整的重寫代碼,以防與其他內容發生衝突。 – Osprey

+0

更新了模式,但仍然沒有運氣:( – Osprey