Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Relative links forcing https ??
Old 02-18-2009, 05:30 AM Relative links forcing https ??
EdB
Skilled Talker

Posts: 79
Name: Ed Barnett
Trades: 0
Hi everyone,

I've got my SSL and non-SSL pages in one directory on our webserver (for ease). I want to use relative links (rather than absolute links) but am not sure how to force the browser to use the SSL certificate and make it https:// without using absolute links.

The site is written in PHP and the code would be as follows;

Header ("Location: index.php");
^ How can i specify that to go to the relative page using SSL?

Also, when a link is SSL encrypted e.g. https://www.this.com/login.php how can I force a relative link to a non-SSL encrypted page?

Thanks in advance guys!

Last edited by EdB; 02-18-2009 at 07:26 AM..
EdB is offline
Reply With Quote
View Public Profile Visit EdB's homepage!
 
 
Register now for full access!
Old 02-18-2009, 10:35 AM Re: Relative links forcing https ??
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
PHP Code:
header("Location: https://www.site.com/index.php"); // just put the secure link in. 
Then to force them to always use SSL on your websie use

PHP Code:
<?php
    
if( $_SERVER['SERVER_PORT'] == 80) {
        
header('Location:https://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/'.basename($_SERVER['PHP_SELF']));
        die();
    }
?>
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE

Last edited by rogem002; 02-18-2009 at 10:38 AM..
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 02-19-2009, 07:08 AM Re: Relative links forcing https ??
EdB
Skilled Talker

Posts: 79
Name: Ed Barnett
Trades: 0
Hi Rogem002.

Thanks for your reply but that's not quite what I had in mind.

I would like to be able to use relative links (e.g. index.php) instead of absolute links (e.g. http://www.site.com/index.php) to transfer from a secure page https:// to a non-secure page http:// and vice versa. So if my page was;

https://www.site.com/admin/logout.php

I want to be able to go to the index.php of the site e.g. http://www.site.com/index.php using a relative link.
EdB is offline
Reply With Quote
View Public Profile Visit EdB's homepage!
 
Old 02-19-2009, 07:28 PM Re: Relative links forcing https ??
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
Fine, then make the site.com/index.php include this text.

PHP Code:
<?php
// Credits to rogem002 from a few posts above.
    
if( $_SERVER['SERVER_PORT'] == 443) {
        
header('Location: http://'$_SERVER['PHP_SELF']);
    }
?>
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Old 02-20-2009, 05:13 AM Re: Relative links forcing https ??
EdB
Skilled Talker

Posts: 79
Name: Ed Barnett
Trades: 0
Quote:
Originally Posted by Decaf View Post
Fine, then make the site.com/index.php include this text.

PHP Code:
<?php
// Credits to rogem002 from a few posts above.
    
if( $_SERVER['SERVER_PORT'] == 443) {
        
header('Location: http://'$_SERVER['PHP_SELF']);
    }
?>
Apologies, that was a blonde moment indeed. Thank you both for the help
EdB is offline
Reply With Quote
View Public Profile Visit EdB's homepage!
 
Reply     « Reply to Relative links forcing https ??
 

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.44084 seconds with 12 queries