The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

need redirect to https://

Discussion in 'General Discussion' started by logikstudios, Aug 29, 2007.

  1. logikstudios

    logikstudios Well-Known Member

    Joined:
    Nov 2, 2006
    Messages:
    158
    Likes Received:
    0
    Trophy Points:
    0
  2. DReade83

    DReade83 Well-Known Member

    Joined:
    Oct 20, 2006
    Messages:
    196
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Cheshire, UK
    Use PHP code to force HTTPS. I did with a client's site and it worked a treat...

    Code for forcing a HTTPS connection where needed:
    PHP:
    <?php
        
    if($HTTP_SERVER_VARS["HTTPS"] == "off") {
            
    header("Location: https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);
        }
    ?>
    Code for forcing a HTTP connection where needed:
    PHP:
    <?php
        
    if($HTTP_SERVER_VARS["HTTPS"] == "on") {
            
    header("Location: http://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);
        }
    ?>
    Enjoy! :D
     
  3. logikstudios

    logikstudios Well-Known Member

    Joined:
    Nov 2, 2006
    Messages:
    158
    Likes Received:
    0
    Trophy Points:
    0
    Hi. Is there an easier way of doing this? I would prefer this to be at domain lever rather than at the code.

    Thanks,
     
  4. maggy

    maggy Active Member

    Joined:
    Jun 9, 2004
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    1
    use an apache rewrite in httpd.conf
     
Loading...

Share This Page