I am using this answer https://*.com/a/13861795/848513 which works great for static files, which no longer exist on my site, to forwards to new file locations.
我正在使用这个答案https://*.com/a/13861795/848513,它非常适用于我的网站上不再存在的静态文件转发到新的文件位置。
But I also have some dynamic URL's that need to be forwarded to new locations, and the following code doesn't seem to work:
但我也有一些需要转发到新位置的动态URL,以下代码似乎不起作用:
Works:
<rule name="SpecificRedirect50" stopProcessing="true">
<match url="aboutus.php" /> <!-- static URL -->
<action type="Redirect" url="/about-us" redirectType="Permanent" />
</rule>
Does not work:
不起作用:
<rule name="SpecificRedirect1" stopProcessing="true">
<match url="topic.php?id=39" /> <!-- dynamic URL-->
<action type="Redirect" url="/folder/?id=520" redirectType="Permanent" />
</rule>
The error i get when trying to go to www.site.com/topic.php?id=39 is a 404 Not Found error - ie, it isn't being filtered by the rewrite script.
尝试访问www.site.com/topic.php?id=39时出现的错误是404 Not Found错误 - 即,它没有被重写脚本过滤。
What should the format be?
格式应该是什么?
Thanks
1 个解决方案
#1
OK, found answer - this format works:
好的,找到答案 - 这种格式有效:
<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>
#1
OK, found answer - this format works:
好的,找到答案 - 这种格式有效:
<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>