1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to ridirect http to https with uot .htaccess

Discussion in 'Site & Server Administration' started by Kaiti, Nov 21, 2017.

  1. #1
    there is some way to redirect from http to https withuot .htaccess
     
    Kaiti, Nov 21, 2017 IP
  2. phpmillion

    phpmillion Member

    Messages:
    145
    Likes Received:
    11
    Best Answers:
    4
    Trophy Points:
    45
    #2
    .htaccess is surely the best way to do this, but you can also redirect traffic to https using PHP

    if(empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "off"){
        $redirect = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
        header('HTTP/1.1 301 Moved Permanently');
        header('Location: ' . $redirect);
        exit();
    }
    Code (markup):
     
    phpmillion, Nov 22, 2017 IP
  3. Kaiti

    Kaiti Active Member

    Messages:
    123
    Likes Received:
    7
    Best Answers:
    1
    Trophy Points:
    68
    #3
    where I add this? Please
     
    Kaiti, Nov 22, 2017 IP
  4. phpmillion

    phpmillion Member

    Messages:
    145
    Likes Received:
    11
    Best Answers:
    4
    Trophy Points:
    45
    #4
    At the top of PHP file(s). Before any other code.
     
    phpmillion, Nov 23, 2017 IP
  5. Kaiti

    Kaiti Active Member

    Messages:
    123
    Likes Received:
    7
    Best Answers:
    1
    Trophy Points:
    68
    #5
    I can add in index.php or in header.php?
     
    Kaiti, Nov 23, 2017 IP
  6. phpmillion

    phpmillion Member

    Messages:
    145
    Likes Received:
    11
    Best Answers:
    4
    Trophy Points:
    45
    #6
    At the top of your PHP file(s). It impossible to tell which file exactly you need to add this code to, because only you know the structure of your files.
     
    phpmillion, Nov 24, 2017 IP
  7. Kaiti

    Kaiti Active Member

    Messages:
    123
    Likes Received:
    7
    Best Answers:
    1
    Trophy Points:
    68
    #7
    I'm using Wordpress
     
    Kaiti, Nov 24, 2017 IP
  8. phpmillion

    phpmillion Member

    Messages:
    145
    Likes Received:
    11
    Best Answers:
    4
    Trophy Points:
    45
    #8
    Then simply look at WordPress files to check which files are served first, and include code there.
     
    phpmillion, Nov 24, 2017 IP