Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

How to make redirect from http to https

How to redirect from http to https.


1. redirect http://example.com to https://www.example.com
2. redirect http://www.example.com to https://www.example.com
3. redirect https://example.com to https://www.example.com

Like facebook, google ??

Please help me with code in .htaccess or another
you would need to use the .htdocs and code it up there for it..pm me your skype and ill be able to help u with it.
You're running a web hosting business and you don't know how to do basic rewrites? Eek.

Are you using Apache, Nginx, or something else?
There are many ways to achieve this. If you are using PHP you can do it with a code like this:
PHP Code

<?php 
//
// FORCE SSL 
//
    // Use HTTP Strict Transport Security to force client to use secure connections only
    
$use_sts = false;

    
// iis sets HTTPS to 'off' for non-SSL requests
    
if ($use_sts && isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
        
header('Strict-Transport-Security: max-age=31536000');
    } elseif (
$use_sts) {
        
header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], true, 301);
        
// we are in cleartext at the moment, prevent further execution and output
        
die();
    }
//
// FORCE SSL END
// 
IF SSL is installed on your server.

Forcefully Redirect http to https via .htaccess file

""""""
RewriteEngine On
RewriteCond %{HTTP_HOST} ^websitedomain\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://websitedomain.com/$1 [R,L]
""""""


Possibly Related Threads...
Thread / Author Replies Views Last Post
by James BurnhamSep 3, 2019 12:42 AM 3 152 Sep 3, 2019 12:42 AM
Last Post: Squito
by Account of the GodsJan 25, 2017 12:58 AM 4 136 Jan 25, 2017 12:58 AM
Last Post: Squito
by HubertDec 31, 2016 04:50 PM 2 145 Dec 31, 2016 04:50 PM
Last Post: 'Ben