Redirecionar HTTP para HTTPS com Windows Server (IIS)
Basta:
- Criar o arquivo web.config e adicionar em httpdocs da sua hospedagem ou editar o arquivo se já tiver no servidor.
- Adicionar o código abaixo no web.config:
<configuration> <system.webServer> <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="Permanent" url="https://{HTTP_HOST}/{R:1}" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
Atenção: Somente efetue o procedimento abaixo se seu site estiver usando um certificado SSL em seu domínio.