要实现IIS上的这种域名重定向,你可以使用URL重写模块来配置重定向规则。以下是一个基本的web.config配置示例,它实现了你的需求:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="301Redirect-1" stopProcessing="true"> <match url="(.*)" /> <conditions logicalGrouping="MatchAny"> <add input="{HTTP_HOST}" pattern="^wan-qi\.cn$" /> </conditions> <action type="Redirect" url="https://www.wan-qi/{R:0}" redirectType="Permanent" /> </rule> <rule name="Redirect to https" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions logicalGrouping="MatchAll"> <add input="{HTTP_FROM_HTTPS}" pattern="^on$" negate="true" /> </conditions> <action type="Redirect" url="https://www.wan-qi.cn/{R:1}" redirectType="Permanent" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
建站咨询热线
029-33273980