Results 1 to 2 of 2

Thread: Redirecting to non HTTPS protocol in IE

  1. #1
    Join Date
    Jan 2011
    Posts
    19

    Redirecting to non HTTPS protocol in IE

    Hi, I have a page that goes on a loop when I try to use the following functions in Internet Explorer:

    PHP Code:
    function redirectToHTTPS(){
                    if(
    $_SERVER['HTTPS']!="on"){
                        if(
    $_SERVER['HTTP_HOST'] == "www.peeka.com"){
                            
    $redirect"https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
                        }else{
                            
    $redirect"https://www.".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
                        }
                        
    header("Location:$redirect");
                    }
                }
                
                function 
    redirectToNonHTTPS(){
                    if(
    $_SERVER['HTTPS']=="on"){
                        if(
    $_SERVER['HTTP_HOST'] == "www.peeka.com"){
                            
    $redirect"http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
                        }else{
                            
    $redirect"http://www.".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
                        }
                    }elseif(
    $_SERVER['HTTP_HOST'] == "peeka.com"){
                        
    $redirect"http://www.".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
                    }
                    
    header("Location:$redirect");
                } 
    How do I get around this? Thanks.

  2. #2
    Join Date
    Apr 2009
    Location
    The toon
    Posts
    1,225
    I wouldn't do it using PHP

    Do it in your .htaccess file

    Code:
    RewriteEngine on
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [NC,R,L]
    Try here for more options....

    http://bit.ly/nwfQr

Similar Threads

  1. Controlling https:// destination
    By The doomed in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 01 Oct 2008, 09:38 AM
  2. Using HTTPS for site login...
    By DrWebber in forum General Questions
    Replies: 0
    Last Post: 05 Nov 2007, 06:45 AM
  3. Ebay Script: CURL in HTTPS [HELP PLEASE]
    By NahiaN in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 11 Sep 2006, 07:28 AM

Posting Permissions

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