Results 1 to 8 of 8

Thread: reading the full URL [resolved]

  1. #1

    Thread Starter
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090

    reading the full URL [resolved]

    How can PHP read whether the URL startes with "http://" or "https://"?

    I did a search and found this:
    http://www.vbforums.com/showthread.p...ighlight=https
    which said I should try this:
    PHP Code:
    echo $_SERVER['HTTPS']; 
    But I get this error:
    Notice: Undefined index: HTTPS in c:\mina dokument\icefire security\test.php on line 2
    Last edited by Acidic; Jul 22nd, 2004 at 01:23 PM.
    Have I helped you? Please Rate my posts.

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I've never heard of $_SERVER['HTTPS'], and it's not in my manual. It gives you that notice because that variable is not defined.

    Give this a try:

    Code:
    $_SERVER['SERVER_PROTOCOL'];
    I'm not sure how to test it to see what it returns when you access it with https, but it might be what you're looking for.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I just found this in the comments of the manual:

    I find that to tell whether a script is running under http:// or https:// I need to check and see if $_SERVER['HTTPS'] is set. FreeBSD 4.8, Apache.
    So maybe it is something. Try:

    Code:
    if (isset($_SERVER['HTTPS'])) {
        echo 'I was accessed via HTTPS.';
    } else {
        echo 'I was accessed via HTTP.';
    }
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    ($_SEVER
    SEVER or SERVER?



    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by techgnome
    SEVER or SERVER?



    Tg
    You're not a hardcore PHP programmer if you've never used the $_SEVER variable.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    SEVER? It's SEWER you $&@(% N00B!!!

    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Originally posted by CornedBee
    SEVER? It's SEWER you $&@(% N00B!!!

    OH, but of COURSE it is..... Geeez, no wonder it wouldn't work for me.

    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8

    Thread Starter
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    OK. This works perfectly:
    PHP Code:
    <?
    if (isset($_SERVER['HTTPS'])) {
        echo 'I was accessed via HTTPS.';
    } else {
        echo 'I was accessed via HTTP.';
    }
    ?>
    Thank you so much.

    Since I'm not uber PHP coder I think i'll stick to SERVER for now.
    Have I helped you? Please Rate my posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width