Jump to content

[SOLVED] switching from http to httpS


acidglitter

Recommended Posts

for one of the sites i'm working on, for like the login and checkout pages they want the site to be secure (httpS). so i updated the links to those pages to include the S in http, but once a visitor is on those pages, if they click a regular link, like the homepage, it will still be secure. i tried (kind of a lazy way) putting <base href="http://www.site.com/"> so the regular links won't have the S, but now in internet explorer i'm getting the message "this page contains both secure and nonsecure items". is there an easy way to use php to fix this problem?

Link to comment
Share on other sites

There's a few things you could try

 

1.  Detect in php if you are on a non-login non-checkout page and using https.  If yes, issue a 302 redirect to the non-secure version of that page

 

2.  Generate the links in php, ensuring that links to pages that should not be encrypted are http, and vice versa.

Link to comment
Share on other sites

I'm sure you can tell from one of the $_SERVER variables.  Are you familiar with phpinfo() ? Run a script like this:

 

<?php echo phpinfo(); ?>

 

That will show you what variables are available that might tell you if the connection is secure or not.

Link to comment
Share on other sites

yea that fixed it ^_^; so what i'm doing now is in the header file i have

 

if(isset($_SERVER['HTTPS']) && !isset($keepthispagesecure)){
header("Location: http://www.site.com{$_SERVER['REQUEST_URI']}");
exit;
}

 

and in the login (and other) pages i set the $keepthispagesecure variable before including the header. this seems to have fixed all of my problems :) now only specific pages are secure and internet explorer is happy :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.