问:域名设置主域名跳转到带www的域名,一直无法生效,按照官网教程设置了都不行,设置如下:<rule name="301Redirect" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^abc1.com$" />
<add input="{HTTP_HOST}" pattern="^abc2.com$" />
</conditions>
<action type="Redirect" url="http://www.abc1.com/{R:0}" redirectType="Permanent" />
</rule><rule name="301" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false"></match> <conditions logicalGrouping="MatchAll"> <add input="{HTTP_FROM_HTTPS}" pattern="^on$" negate="true"></add> </conditions> <action type="Redirect" url="https://www.sryun.net/{R:1}" redirectType="Permanent"></action></rule>
以上2种设置都不起作用,应该如何设置?我系统是2016,用的建站助手。
附上我现在的web.config文件内容:
<?xml version="1.0" encoding="UTF-8"?><configuration> <system.webServer> <rewrite> <rules> <rule name="HttpToHttps" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="off" ignoreCase="true" /> </conditions> <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" /> </rule> <rule name="301Redirect" stopProcessing="true"> <match url="(.*)" /> <conditions logicalGrouping="MatchAny"> <add input="{HTTP_HOST}" pattern="^sryun.net$" /> </conditions> <action type="Redirect" url="https://www.sryun.net/{R:0}" redirectType="Permanent" /> </rule> <clear /> </rules> </rewrite> <handlers> <remove name="PHP_FastCGI" /> <add name="isapi" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" preCondition="classicMode,runtimeVersionv4.0,bitness32" /> </handlers> <httpRedirect enabled="false" destination="https://www.sryun.net" exactDestination="true" httpResponseStatus="Permanent" /> <modules runAllManagedModulesForAllRequests="true"> <remove name="UrlRoutingModule" /> </modules> </system.webServer> </configuration>
,301跳转都不起作用
问:用这段好像已经起作用了。<rule name="301" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions logicalGrouping="MatchAll"> <add input="{HTTPS}" pattern="^on$" negate="true" /> </conditions> <action type="Redirect" url="https://www.sryun.net/{R:1}" redirectType="Permanent" /> </rule>