Como fazer usando PHP:
<?phpif($_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]