hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : PHP and SSL
Reply

Forum Jump

PHP and SSL

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old
Junior Guru Wannabe
 
Join Date: Aug 2002
Posts: 35

PHP and SSL


Is there anyway to use relative addressing and specify that a page needs to be loaded via SSL?

Or do you always have to use absolute addressing (e.g. "https://www.foo.com/foo.php")?

--Bruce



Sponsored Links
  #2  
Old
Disabled
 
Join Date: Aug 2002
Posts: 1,216
Good question, i've been wondering the same .

  #3  
Old
Web Hosting Master
 
Join Date: May 2002
Location: Edmonton, Canada
Posts: 978
Use .htaccess on a directory, domain, or subdomain and set a rewrite condition forcing all http:// to https://

-Matt

__________________
Matt Meier, RackNine Inc.
email: mmeier@racknine.com
web: http://www.racknine.com

Sponsored Links
  #4  
Old
Web Hosting Master
 
Join Date: May 2002
Location: Edmonton, Canada
Posts: 978
Or - if you desire - track the port the user's connecting to($_SERVER['SERVER_PORT']) and if 80 do a header('location: ...'); pointing to https.

-Matt

__________________
Matt Meier, RackNine Inc.
email: mmeier@racknine.com
web: http://www.racknine.com

  #5  
Old
Disabled
 
Join Date: Aug 2002
Posts: 1,216
Hmm, are there any other ways?

  #6  
Old
Junior Guru Wannabe
 
Join Date: Aug 2002
Posts: 35
RackNine,

Could you post an example please?

--Bruce

  #7  
Old
Disabled
 
Join Date: Aug 2002
Posts: 1,216
What he's saying is

PHP Code:
<?php
if($_SERVER['SERVER_PORT'] == "80")
{
header('location: [url]https://domain.com[/url]');
exit;
}
?>
Which is pretty much still a "force push" as you have to point it to either https://domain.com, or https://www.domain, instead of it pushing from the current location of the user ie user is at http://domain.com, script pushes him to https://www.domain.com ;o).

  #8  
Old
Junior Guru Wannabe
 
Join Date: Aug 2002
Posts: 35
Thanks for the example, but I was really asking for an example of the .htaccess mrthod.

I understand the header(location: xxx) method, but I was asking about sending the user to https via a call to a page relative to the current page, without having to specify the complete URL.

--Bruce

  #9  
Old
Web Hosting Master
 
Join Date: Jan 2002
Location: Kuwait
Posts: 679
There is no way to do that using HTML. You either use JavaScript or a server side solution (PHP, CGI, mod_rewrite, ASP, ..)

__________________
Ahmad Alhashemi
PHP, Apache, C, Python, Perl, SQL
18 related BrainBench certificates

  #10  
Old
Web Hosting Guru
 
Join Date: Oct 2001
Posts: 307
With PHP:

PHP Code:
if($_SERVER['SERVER_PORT'] != "443") {
    
$newURL "https://" $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_URL'];
    
header("location: $newURL");
    exit;
}
?> 
With mod_rewrite... tested in .htaccess:
Code:
RewriteEngine On 
RewriteCond %{SERVER_PORT} !^443$ 
RewriteRule ^(.*)         https://%{SERVER_NAME}/$1 [R]

__________________
Adam
GetWebSpace.com
Personal Life Timed Out Due To Inactivity

Reply

Related posts from TheWhir.com
Title Type Date Posted


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
WHT Host Brief Email:

We respect your privacy. We will never sell, rent, or give away your address to any outside party, ever.

Advertisement:
Web Hosting News:
WHT Membership
WHT Membership



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?