我们已将网站从 php apache 网站移至 asp.net mvc 网站,我试图让特定的重定向正常工作,但遇到了困难。
基本上我想要任何关于 http://www.mysite.com/index.php?pr=about_us 的请求被重定向到http://www.mysite.com/About-Us
我已经尝试过这个,但它不起作用。有什么想法吗?
<rewrite>
<rules>
<rule name="About Us" stopProcessing="true">
<match url="index.php?pr=About_Us" ignoreCase="false" />
<action type="Redirect" redirectType="Permanent" url="http://www.mysite.com/About-Us" />
</rule>
</rules>
</rewrite>
这个我也试过了,但是还是不行。
<httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Permanent">
<add wildcard="index.php?pr=About_Us" destination="/About-Us" />
</httpRedirect>
我有大约十几个这样的特定重定向,我需要将它们实现到各个页面。
非常感谢任何帮助! 谢谢
最佳答案
试试这个:
<rule name="About Us" stopProcessing="true">
<match url="^(.*)$">
<conditions>
<add input="{URL}" pattern="index.php?pr=About_Us" />
</conditions>
</match>
<action type="Redirect" redirectType="Permanent" url="http://www.mysite.com/About-Us" />
</rule>
编辑
这是条件的另一种可能性:
<conditions logicalGrouping="MatchAll">
<add input="{QUERY_STRING}" pattern="?pr=About_Us" />
<add input="{REQUEST_FILENAME}" pattern="index.php" />
</conditions>
编辑 - 工作解决方案
<rule name="About Us" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{QUERY_STRING}" pattern="/?pr=About_Us$" />
<add input="{REQUEST_FILENAME}" pattern="index.php" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="http://www.mysite.com/About-Us" />
</rule>
关于将特定页面重定向到 iis web.config 中的另一个特定页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10576659/