我想重定向来自
的所有流量https://url
到
https://www.url
如何编写重定向网址?:
<rewrite>
<rules>
<rule name="Add www prefix">
<match url="(.*)" ignoreCase="true" />
<action type="Redirect" url="what to put here?" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
答案 0 :(得分:0)
你试过这样做吗
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Add www" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTP_HOST}" pattern="www.YOURWEBSITE.com" negate="true" />
</conditions>
<action type="Redirect" url="http://www.YOURWEBSITE.com/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
您可以找到更多here
答案 1 :(得分:0)
尝试这样的事情:
<rules>
<rule name="www redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://www.{HTTP_HOST}/{R:1}" />
</rule>
</rules>
根据您的需要调整,但我认为它有效。