我们的香港空间部分是windows下的IIS平台,一些用户安装了SSL https证书后,不会控制301跳转,下面直接贴出代码,根据需要把代码放到web.config文件里即可。 http跳转到https这个代码段是http重定向到https, 注意,要放在<rules>和</rules>之间。 <rule name="HTTP to HTTPS redirect" 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> http跳转到https提醒:里面的网址记得改成你自己的网站,别懒得只会copy! 这个代码段是无3w重定向到有3w域名, 注意,要放在<rules>和</rules>之间。 <rule name="www" stopProcessing="true"> <match url=".*" /> <conditions> <add input="{HTTP_HOST}" pattern="^ip110\.com$" /> </conditions> <action type="Redirect" url="https://www./{R:0}" /> </rule> 完整的web.config代码下面代码包含了,无3w网址,跳转到有3w网址; 以及, http全部跳转到https 当然了,知道大家懒,已经将两份整合到一起,将下面全部代码保存成web.config文件,存放到空间的web目录下即可。再次提醒:里面的网址记得改成你自己的网站,别懒得只会copy! <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="www" stopProcessing="true"> <match url=".*" /> <conditions> <add input="{HTTP_HOST}" pattern="^ip110\.com$" /> </conditions> <action type="Redirect" url="https://www./{R:0}" /> </rule> <rule name="HTTP to HTTPS redirect" 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> </rules> </rewrite> </system.webServer> </configuration> |
|