[英]redirect website to url with www using web.config
我正在尝试使用web.config进行重定向
如果网址是http://xyzsample.com
我想将其重定向到http://www.xyzsample.com
我尝试了以下代码
<rule name="Imported Rule 1-1" enabled="true" stopProcessing="true">
<match url="^(*.*)$" ignoreCase="true" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="xyzsample.com" />
</conditions>
<action type="Redirect" url="http://www.xyzsample.com/{R:1}" redirectType="Permanent" />
</rule>
但这不重定向,并且导致500 internal server error
试试下面的代码。 我以前用过
<rewrite>
<rules>
<rule name="Redirect to non-www" stopProcessing="true">
<match url="(.*)" negate="false"></match>
<action type="Redirect" url="http://domain.com/{R:1}"></action>
<conditions>
<add input="{HTTP_HOST}" pattern="^domain\.com$" negate="true"></add>
</conditions>
</rule>
</rules>
</rewrite>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.