IIS重定向规则配置求助:Webinar地址Product1转至Product2
IIS URL重定向规则修正方案
你的重定向规则未生效主要存在两个问题,以下是修正后的配置及说明:
<rewrite> <rules> <rule name="v2-r1" stopProcessing="true"> <match url="^webinars/Product1" /> <action type="Redirect" url="/webinars/Product2" appendQueryString="true" /> </rule> <rule name="Hide-Controller" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> </conditions> <action type="Rewrite" url="index.php" appendQueryString="true" /> </rule> </rules> </rewrite>
修改点说明:
- 移除
match url开头的斜杠:IIS Rewrite模块的match url属性匹配的是请求路径中去掉站点根目录后的部分,无需开头的/,原规则里的^/webinars/Product1无法匹配到正确路径。 - 给重定向规则添加
stopProcessing="true":当这条重定向规则匹配成功后,直接停止后续规则执行,避免不必要的处理,同时确保重定向动作优先完成。 - 第二条
Hide-Controller规则配置无问题,会在请求非静态文件时将路径重写到index.php,保留原有逻辑即可。
内容的提问来源于stack exchange,提问作者Essex Steph
相关产品推荐
相关产品推荐

