PHPBuilder - Switching between the http to https and vice versa



RSS Twitter
Tips Application Architecture

Switching between the http to https and vice versa

by: Siddhu
|
February 3, 2003

// ssl certficate must be installed for your site
// include the page where the function is defined
require ('sslredirection.php'); // copy paste the below code on the every page
<?SSlRedirection($PHP_SELF)?>

// write the following code in the page called sslredirection.php
// function which do the necessary things
// it takes the page name as input type parameter

<? function SSlRedirection($sVal)
{
global $SERVER_NAME; // your server name
global $SERVER_PORT; // server port
$strSSLPageName = "test.php"; // the page name which should be on the https <bt>if(($sVal == $strSSLPageName))
{
if($SERVER_PORT == 80)
{
$strRedirectUrl = "https://".$SERVER_NAME.$sVal;
header("Location: $strRedirectUrl");
}
}
else
{
if ($SERVER_PORT == 443)
{
$strRedirectUrl = "http://".$SERVER_NAME.$sVal;
header("Location: $strRedirectUrl");
}
}
} ?>

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Siddhu

Comment:



Comment:

(Maximum characters: 1200). You have characters left.