2017-08-11 83 views
1

我很努力讓301重定向工作,當url包含一個&符號在iis。我使用的代碼如下:IIS 8.5 - 301重定向和&符號

<rewrite> 
     <rules> 
      <rule name="Redirect rule1 for 301-maps"> 
       <match url=".*" /> 
       <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> 
        <add input="{301-maps:{REQUEST_URI}}" pattern="(.+)" /> 
       </conditions> 
       <action type="Redirect" url="{C:1}" appendQueryString="false" /> 
      </rule> 
     </rules> 
    </rewrite>   

     <rewriteMaps> 
      <rewriteMap name="301-maps"> 
      <add key="/mobile/product.htm?id=139" value="/" /> << works 
      <add key="/mobile/product.htm?id=139&subid=1" value="/" /> << fails syntax 

回答

0

所有你需要的是什麼,是代替&使用&amp;。您的重寫地圖網址應爲:

<add key="/mobile/product.htm?id=139&amp;subid=1" value="/" /> 

在XML中,你需要逃離這個5個符號:

" &quot; 
' &apos; 
< &lt; 
> &gt; 
& &amp; 
+0

織補,以爲我試過,但不能有;解決方案工作 – Tfx77