www.webdeveloper.com
Results 1 to 2 of 2

Thread: Redirect from http to https

  1. #1
    Join Date
    Jun 2003
    Posts
    72

    Question Redirect from http to https

    I have a small redirect problem. We have a donation page located on our server...

    c:/siteinfo/root/donation/index.php

    The page http://www.oursite.com/donation is not secure.
    However, the page https://www.oursite.com/donation is secure.

    Someone in our organization sent people a link to the unsecure http page, and not the https page. We need to redirect people to the correct URL (otherwise, people will get an unsecure message, and wont donate).

    Since the index.php page is the same for http and https ... we can't do a simple page redirect (because the page will constantly be redirecting the person over and over again - if they are on the http page, it will redirect them to the https page ... but then it will redirect them again to the https page ... and again ... and again ... a constant loop)

    So, we need another solution. Can someone help us with this?

  2. #2
    Join Date
    Dec 2005
    Posts
    2,984
    On the top of your donation page:
    PHP Code:
    <?php
      
    if(empty($_SERVER['HTTPS'])) {
        
    header('Location: https://oursite.com/donation');
        exit;
      }
    ?>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles