这边是以Window Server为架构
前置作业
1.你要有申请SSL凭证,并安装到Server
2.你的IIS的扩充模组安装URL Rewrite
当以上前置作业都完成,就可以到web.config档里面,设定转址规则啰~
以下就你想将HTTP协定转成HTTPS的做法
<rewrite> <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> </rules></rewrite>
当然如果你觉得不想再付凭证费了,也是可以降回HTTP协定,但是在到期之前,就要先下转回的规则唷
否则你在搜寻引擎的网站列出,连结的网址在还没有变回HTTP协定以前,点过去都会出现凭证错误的警告唷
<rewrite> <rules> <rule name="HTTPS to HTTP redirect" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="%{HTTPS}" pattern="on" ignoreCase="true" /> </conditions> <action type="Redirect" redirectType="Found" url="http://{HTTP_HOST}/{R:1}" /> </rule> </rules></rewrite>
纪录...