Webconfig规则中通配符URL的301重定向

问题描述 投票:-1回答:1

我尝试了很多...我没有使域重定向

301重定向到通配符URL

我有https://www.example.com/blog通配符-https://blog.example.com/

我需要将此域[[https://www.example.com/blog重定向到此一个https://blog.example.com/

/到https://blog.example.com/的博客

<rule name="Redirect blog" stopProcessing="true"> <match url=".*" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> <add input="{HTTP_HOST}" pattern="/blog$" /> </conditions> <action type="Redirect" url="https://blog.example.com/" redirectType="Permanent"/> </rule>
c# .net redirect iis http-status-code-301
1个回答
0
投票
您可以使用{PATH_INFO}代替{HTTP_HOST}

<rule name="Redirect blog" stopProcessing="true"> <match url=".*" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> <add input="{PATH_INFO}" pattern="/blog$" /> </conditions> <action type="Redirect" url="https://blog.example.com/" redirectType="Permanent"/> </rule>

© www.soinside.com 2019 - 2024. All rights reserved.