function redirectToHTTPS()
{
  if($_SERVER['HTTPS']!="on")
  {
     $redirect= "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
     header("Location:$redirect");

  }
}
Member Avatar for TechySafi

Most hosting providers will have a file structure already set in place. If your hosting provider is like mine, there'll be several key folders: HTTPdocs is the area to place your non-encrypted data and documents. HTTPSdocs is the area to place all your site pages and components that you would like encrypted by the SSL certificate.

see at http://www.htmlgoodies.com/beyond/reference/article.php/3472781/So-You-Want-Your-Pages-to-be-Encrypted-Huh.htm
and

header("Location: $redirect");

Any other problem?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.