|
-
Jul 21st, 2004, 11:43 AM
#1
Thread Starter
Frenzied Member
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. 
-
Jul 21st, 2004, 02:52 PM
#2
Stuck in the 80s
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.
-
Jul 21st, 2004, 02:54 PM
#3
Stuck in the 80s
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.';
}
-
Jul 21st, 2004, 02:55 PM
#4
SEVER or SERVER?
Tg
-
Jul 21st, 2004, 02:56 PM
#5
Stuck in the 80s
Originally posted by techgnome
SEVER or SERVER?
Tg
You're not a hardcore PHP programmer if you've never used the $_SEVER variable.
-
Jul 22nd, 2004, 07:36 AM
#6
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.
-
Jul 22nd, 2004, 08:35 AM
#7
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
-
Jul 22nd, 2004, 01:22 PM
#8
Thread Starter
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|