2015-05-04 95 views
0

我正在使用这个答案https://stackoverflow.com/a/13861795/848513,它非常适合我的站点上不再存在的静态文件转发到新的文件位置。IIS URL重写 - 带有动态文件

但我也有一些动态的URL需要被转移到新的地点,和下面的代码似乎并没有工作:

作品:

<rule name="SpecificRedirect50" stopProcessing="true"> 
     <match url="aboutus.php" /> <!-- static URL --> 
     <action type="Redirect" url="/about-us" redirectType="Permanent" /> 
    </rule> 

不起作用:

<rule name="SpecificRedirect1" stopProcessing="true"> 
     <match url="topic.php?id=39" /> <!-- dynamic URL--> 
     <action type="Redirect" url="/folder/?id=520" redirectType="Permanent" /> 
    </rule> 

尝试访问www.site.com/topic.php?id=39时出现的错误是404未找到错误 - 即,它未被重写脚本过滤。

格式应该是什么?

感谢

回答

0

OK,找到答案 - 这种格式的工作原理:

<rule name="SpecificRedirect1111" stopProcessing="true"> 
     <match url="^topic\.php$" /> 
     <conditions> 
      <add input="{QUERY_STRING}" pattern="^id=39$" /> 
     </conditions> 
     <action type="Redirect" url="/folder/?id=520" appendQueryString="false" redirectType="Permanent" /> 
    </rule>