以下方式采取的是IIS: “URL 重写” 或者 “URL Rewrite” 模块
替换或增加网站根目录文件:web.config。
指定1个域名跳转
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="HTTPS" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions logicalGrouping="MatchAll"> <add input="{http_host}" pattern="^gworg.com" /> </conditions> <action type="Redirect" url="https://www.gworg.com/{R:1}" redirectType="Permanent" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
指定多个域名跳转HTTPS方式
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <clear /> <rule name="Gworg" stopProcessing="true"> <match url="^(.*)$" /> <conditions> <add input="{HTTPS}" pattern="^OFF$" /> <add input="{HTTP_HOST}" pattern="^www\.gworg\.com$|^gworg\.com$" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
指定多个域名跳转HTTPS方式(备用代码,可能无效)
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <clear /> <rule name="https" stopProcessing="true"> <match url="(.*)" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> <add input="{HTTPS}" pattern="^OFF$" /> <add input="{HTTP_HOST}" pattern="^pay2\.gworg1\.cn$|^pay\.gworg2\.net$|^pay2\.gworg3\.org$|^pay3\.gworg4\.com$|^pay2\.gworg5\.org$|^pay\.gworg6\.cn$" negate="true" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" /> </rule> </rules> </rewrite> </system.webServer> </configuration>