Hi how to redirect http to https using php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sbettadpur
    New Member
    • Aug 2007
    • 121

    Hi how to redirect http to https using php

    Hi everybody,
    Iam facing problem with redirecting http: connection to https:

    Here iam Running my scripts on Apache using normal http request...
    but i want to redirect my http url to https url for securing data
    How should i do this...
    don't say like redirect("Locat ion:https://localhost/index.php");
    because i tried It is not working...

    Please let me know ..? is there any another way to do this...

    If you give reponse for this .Iam very thankful and it will be great.......

    Thanks & regaurds,

    bettadpur
  • nothing1
    New Member
    • Nov 2007
    • 30

    #2
    have you tried header() and remember that is has to be the first thing before anything is outputted?

    Comment

    • nathj
      Recognized Expert Contributor
      • May 2007
      • 937

      #3
      Originally posted by sbettadpur
      Hi everybody,
      Iam facing problem with redirecting http: connection to https:

      Here iam Running my scripts on Apache using normal http request...
      but i want to redirect my http url to https url for securing data
      How should i do this...
      don't say like redirect("Locat ion:https://localhost/index.php");
      because i tried It is not working...

      Please let me know ..? is there any another way to do this...

      If you give reponse for this .Iam very thankful and it will be great.......

      Thanks & regaurds,

      bettadpur
      Hi,

      First of all if you want to use the header for anything at all it needs to happen before any output on the page and that includes whitespace!

      Second, the more specific issue of the https. Do you have an SSL certifcate in place? If so most host will provide you with the required .htacess lines required to use the secure server. It's normally something like:
      Code:
      RewriteEngine On
      RewriteCond %{SERVER_PORT} !^443$
      RewriteRule ^(.*)$ __NEW URL__/$1 [R]
      The new url will contain https:// as the start of the address.

      I admit I have only limited experience with this and this based on a particular host company using a certain type of SSL certificate. So it may be off the wall. Hopefully it will be enough to point you in the right direction.
      Cheers
      nathj

      Comment

      Working...