Urgent: Redirecting HTTPS to HTTP

Discussion in 'Programming' started by xtmx, Jul 24, 2013.

  1. #1
    I used to have an SSL certificate installed on my site, but I found out it was preventing certain users from accessing my site. My webserver (Hiawatha) started having problems, so I switched to Lighttpd. I need to know how to send users to the HTTP site when they attempt access using HTTPS.

    If lighttpd doesn't support this, please suggest a web server that will.
     
    xtmx, Jul 24, 2013 IP
  2. Roger Pelt

    Roger Pelt Active Member

    Messages:
    121
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    53
    #2
    @xtmx: Here is your solution to redirect your user from https to http for lighttpd server.

    Case 1 - use this code to redirect everything
    $HTTPS["scheme"] == "https" {
        # capture vhost name with regex conditiona -> %0 in redirect pattern
        # must be the most inner block to the redirect rule
        $HTTPS["host"] =~ ".*" {
            url.redirect = (".*" => "http://%0$0")
        }
    }
    Code (markup):
    Case 2 - use this code to redirect specific url
    $HTTPS["scheme"] == "https" {
        $HTTPS["host"] =~ ".*" {
            url.redirect = ("^/phpmyadmin/.*" => "http://%0$0")
        }
    }
    Code (markup):
    Case 3 - use this code only for specific vhost and url
    $HTTPS["scheme"] == "https" {
        $HTTPS["host"] == "sth.example.com" {
                url.redirect = ("^/phpmyadmin/.*" => "http://sth.example.com$0")
        }
    }
    Code (markup):
     
    Last edited: Jul 25, 2013
    Roger Pelt, Jul 25, 2013 IP
  3. xtmx

    xtmx Active Member

    Messages:
    359
    Likes Received:
    12
    Best Answers:
    4
    Trophy Points:
    88
    #3
    I already tried that, and it didn't work. After doing some research, I found out it's not possible without an SSL certificate.
     
    xtmx, Jul 25, 2013 IP
  4. Roger Pelt

    Roger Pelt Active Member

    Messages:
    121
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    53
    #4
    The above code only works when you have properly moved SSL certificate on your new server(Lighttpd), so I request you to install SSL on your new server then apply the above code process.
     
    Roger Pelt, Jul 26, 2013 IP