finding protocol

Discussion in 'PHP' started by NoamBarz, Jun 2, 2009.

  1. #1
    I need to find out whether the address someone used to reach a page on my site was using the http or https. I want to disable http access and only allow access to users that use https. Is this possible using php? I tried using $_SEREVER['https'], but the results aren't good enough - it doesn't always work.

    Any idea?
     
    NoamBarz, Jun 2, 2009 IP
  2. givemeknol

    givemeknol Active Member

    Messages:
    22
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    88
    #2
    Could you use "parse_url" function ?
     
    givemeknol, Jun 2, 2009 IP
  3. NoamBarz

    NoamBarz Active Member

    Messages:
    242
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Unfortunately no, because the parse_url function requires that I first find the entire current url and pass it to it. Finding the entire url including the 'http' part is exactly what I'm having a problem with.
     
    NoamBarz, Jun 2, 2009 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    This is definitely possible using .htaccess - at least I would think it is.

    For instance, you can send anyone trying to get to your site using the "http://" to a page displaying "You need to use https:// to reach the content on this website" or something similar.

    And then https:// to go to wherever.

    Unfortunately, I'm not good enough with .htaccess to provide any working code examples.
     
    PoPSiCLe, Jun 2, 2009 IP
  5. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #5
    look a nice function here
     
    crivion, Jun 2, 2009 IP