Welcome Guest, Not a member yet? Register   Sign In
redirect all http:// requests to https:// (SSL)
#2

[eluser]@robertotra[/eluser]
Do not know if it can be done by url rewriting, but it can be done for sure inside the index.php on its top by using the server variable $_SERVER['HTTPS']:

Code:
session_start();
if (empty($_SERVER['HTTPS'])
{
   /* to avoid a potential infinite cicle of redirections, uses a session variable as a flag */
   if ((! isset($_SESSION['redirected'])) || ($_SESSION['redirected'] != 'yes')) {
       $_SESSION['redirected'] = 'yes';
       header('Location: https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);
       exit;
   } else {
       // something wrong, your error catching procedure here
   }
} else {
   // you are on https, reset flag
   $_SESSION['redirected'] = 'no';
}

Anyway, any rewriting or redirection will non ensure images and stylesheets to be loaded by https until you use relative paths. You need to use absolute paths starting with https.

Code:
$GLOBALS['imageDir'] = 'https://yoursite.ext/images/';
<img src="&lt;?php echo $GLOBALS['imageDir']; ?&gt;yourimage.gif">

Roberto


Messages In This Thread
redirect all http:// requests to https:// (SSL) - by El Forum - 02-13-2012, 09:37 AM
redirect all http:// requests to https:// (SSL) - by El Forum - 02-13-2012, 10:19 AM
redirect all http:// requests to https:// (SSL) - by El Forum - 02-13-2012, 12:44 PM
redirect all http:// requests to https:// (SSL) - by El Forum - 02-13-2012, 02:21 PM
redirect all http:// requests to https:// (SSL) - by El Forum - 02-13-2012, 02:29 PM
redirect all http:// requests to https:// (SSL) - by El Forum - 02-13-2012, 02:45 PM
redirect all http:// requests to https:// (SSL) - by El Forum - 02-13-2012, 02:57 PM
redirect all http:// requests to https:// (SSL) - by El Forum - 02-13-2012, 03:20 PM
redirect all http:// requests to https:// (SSL) - by El Forum - 02-13-2012, 10:39 PM
redirect all http:// requests to https:// (SSL) - by El Forum - 02-14-2012, 03:36 AM
redirect all http:// requests to https:// (SSL) - by El Forum - 02-14-2012, 04:08 AM
redirect all http:// requests to https:// (SSL) - by El Forum - 02-14-2012, 04:40 AM
redirect all http:// requests to https:// (SSL) - by El Forum - 02-14-2012, 09:30 AM
redirect all http:// requests to https:// (SSL) - by El Forum - 02-16-2012, 06:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB