Home > Hosting , Programming , Security > Force HTTPS with PHP or. htaccess

Forcing HTTPS with PHP or. Htaccess

If your site uses SSL certificate, learn how to pry open the site only with https:// or file using PHP. Htaccess

How do using PHP:

<?php
if ( $_SERVER [ 'SERVER_PORT' ] != '443' ) {
header( 'Location: https://' . $_SERVER [ 'HTTP_HOST' ]. $_SERVER [ 'REQUEST_URI' ]);
exit ();
}
?>

How to using. Htaccess file (recommended):

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https: //www.seudominio.com.br/$1 [R,L]

This post has been viewed 93 times.


  1. No comments yet.

Spam Protection by WP-SpamFree Plugin