Grab URL PHP code for FaceBook Comments HTTP to HTTPS

Discussion in 'PHP' started by jasonwilks, Jul 25, 2016.

  1. #1
    Hello, I have been using this code to grab the current page URL to input it into my Facebook comments through out my website:

    <?php
    function curPageURL() {
    $pageURL = 'http';
    if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
    $pageURL .= "://";
    if ($_SERVER["SERVER_PORT"] != "80") {
    $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
    } else {
    $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    }
    return $pageURL;
    }
    ?>


    I then use this command to input the URL into my FB comments for all pages:

    <?php echo curPageURL();?>

    It has been working great. But recently I just switch from HTTP to HTTPS on my entire domain. Now all of a sudden I have lost all my facebook comments on all my pages.

    So basically what I need to happen is make it so the Facebook comments are still all on the old HTTP url and not the new HTTPS url. Is there a way I can tweak that code above so that it reverts to the HTTP so I still have all the old FB comments?
     
    jasonwilks, Jul 25, 2016 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    You know that mixing content will trigger warnings in most browsers, right? And in Firefox it won't load at all unless the user allows it.
     
    PoPSiCLe, Jul 25, 2016 IP