Forçar HTTPS com PHP ou .htaccess
1, novembro, 2011
Sem comentários
Se seu site usa certificado SSL, aprenda a forçar a abertura do site somente com o https:// usando PHP ou o arquivo .htaccess
Como fazer usando PHP:
<?php if($_SERVER['SERVER_PORT'] != '443') { header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); exit(); }?>Como fazer usando o arquivo .htaccess (recomendado):
RewriteEngine OnRewriteCond %{SERVER_PORT} 80RewriteRule ^(.*)$ https://www.seudominio.com.br/$1 [R,L]
