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
    SEMrush
     
    Kaiti, Nov 21, 2017 IP
    SEMrush
  2. phpmillion

    phpmillion Member

    Messages:
    136
    Likes Received:
    11
    Best Answers:
    4
    Trophy Points:
    35
    #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:
    85
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    53
    #3
    where I add this? Please
     
    Kaiti, Nov 22, 2017 IP
  4. phpmillion

    phpmillion Member

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

    Kaiti Active Member

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

    phpmillion Member

    Messages:
    136
    Likes Received:
    11
    Best Answers:
    4
    Trophy Points:
    35
    #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:
    85
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    53
    #7
    I'm using Wordpress
     
    Kaiti, Nov 24, 2017 IP
  8. phpmillion

    phpmillion Member

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