Results 1 to 10 of 10
Thread: PHP and SSL
-
09-05-2002, 12:53 PM #1Junior 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
-
09-05-2002, 03:41 PM #2Disabled
- Join Date
- Aug 2002
- Posts
- 1,216
Good question, i've been wondering the same .
-
09-05-2002, 04:32 PM #3Web Hosting Master
- Join Date
- May 2002
- Location
- Edmonton, Canada
- Posts
- 978
-
09-05-2002, 04:34 PM #4Web 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
-
09-05-2002, 04:34 PM #5Disabled
- Join Date
- Aug 2002
- Posts
- 1,216
Hmm, are there any other ways?
-
09-05-2002, 04:35 PM #6Junior Guru Wannabe
- Join Date
- Aug 2002
- Posts
- 35
RackNine,
Could you post an example please?
--Bruce
-
09-05-2002, 04:40 PM #7Disabled
- 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;
}
?>
-
09-05-2002, 06:38 PM #8Junior 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
-
09-06-2002, 01:18 PM #9Web 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, ..)
-
09-07-2002, 03:20 PM #10Web Hosting Guru
- Join Date
- Oct 2001
- Posts
- 315
With PHP:
PHP Code:if($_SERVER['SERVER_PORT'] != "443") {
$newURL = "https://" . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_URL'];
header("location: $newURL");
exit;
}
?>
Code:RewriteEngine On RewriteCond %{SERVER_PORT} !^443$ RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R]