SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2008
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Http - Https redirect issue

    I have certain pages on my website that have SSL enabled and others that don't need it. I used PHP to check what page the user is on and to see if it needs SSL or not. Here is the function:

    PHP Code:
    function redirectToHTTPS() {
        
    $url substr($_SERVER['REQUEST_URI'],1);
        
    $https = array("page1.php","page2.php","etc...");
        if(
    in_array($url,$https) && $_SERVER['HTTPS']!="on") {
            
    $redirect"https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
            
    header("Location:$redirect");
        } elseif(!
    in_array($url,$https) && $_SERVER['HTTPS']=="on") {
            
    $redirect"http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
            
    header("Location:$redirect");
        }

    The problem I am having here is with form processing. If a user processes a form (ie submits data), it submits, then redirects and outputs the wrong message and it gets confusing. Is there a way to do this other than a redirect or maybe though htaccess? Thanks in advance!

  2. #2
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What do you mean wrong message?
    Need to see that code.
    your http/http redirect function looks fine.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2008
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Bah nvm it was a problem with my script not the function. Thanks for looking though!


Bookmarks

Posting Permissions

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