LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-10-2004, 03:19 AM   #1
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Rep: Reputation: 30
how to check if the visitor is using https using php ?


Hello

I am building an ecommerce order page using https .
I am worried because someone could call the pages using http instead of https.

How to check if the visitor is really using https using php or javascript (and automatically redirect him to the same page using https) ?


Thank you
Graziano
 
Old 11-10-2004, 03:54 AM   #2
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
The best way IMHO is to declare https virtual host in a separate directory then the one for the http
virtual host, of course if you don't have access to httpd.conf, it is another story...

You could use something like :
PHP Code:
if( $_SERVER["SERVER_PORT"] != 443 ) {
    
$url "https://".$_SERVER["HTTP_HOST"]."/".$_SERVER["REQUEST_URI"];
    
header("Location: $url");


Last edited by Cedrik; 11-10-2004 at 03:56 AM.
 
Old 11-10-2004, 10:10 AM   #3
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Original Poster
Rep: Reputation: 30
thanks a lot !
 
Old 11-10-2004, 02:55 PM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
A slightly different way:
PHP Code:
if ($_SERVER['HTTPS']!="on") {
    
$url "https://".$_SERVER["HTTP_HOST"]."/".$_SERVER["REQUEST_URI"];
    
header("Location: $url");
    exit;


Last edited by Hko; 11-10-2004 at 03:02 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I check if PHP is installed? imsam Linux - Newbie 8 02-13-2012 02:51 PM
Check if URL is SSL or not in PHP michaelsanford Programming 3 04-14-2010 07:34 AM
php/mysql check varchar() xushi Programming 13 07-15-2005 11:20 AM
Visitor tracking in Perl SiLiCoN Programming 3 04-11-2005 10:36 AM
Visitor Based Networks Mux General 0 12-04-2002 08:10 AM


All times are GMT -5. The time now is 03:05 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration