Https redirect help!

Discussion in 'General Web Coding' started by irvo, Aug 30, 2007.

  1. irvo

    irvo Guppy

    As a relative novice I would be grateful for anyone who could provide me with a way of redirecting all traffic to my http url automatically to the same url but https. I have needed to install ssl for a new site. I have a Windows account using hsphere. Performing a google search provides lots of information relating to error codes and IIs but I wouldn't know where to start with that and there aren't any step by step guides as such. Certainly nothing that seems possible using Hsphere.
  2. Burnt Out

    Burnt Out Perch

    I'm sure there's a better way to do this with DNS settings but that's above my head. If you have ASP you can make a default.asp file with the following:

    <%
    response.redirect "https://yourserver.com"
    %>
  3. Burnt Out

    Burnt Out Perch

    sorry, mis-read your question. if your site was done in asp you could make a simple function that checked the current url and then redirected to the https version. but you would have to add some asp to every page on the website.

    lol, I'm sure there is a better way. just throwing this out there.
  4. Penhall

    Penhall Perch

    <if using ASP pages>

    What about:

    Code:
     
    <%
       If Request.ServerVariables("SERVER_PORT")=80 Then
          Dim strSecureURL
          strSecureURL = "[URL="https://www.yousite.com/"]https://www.yousite.com[/URL]"
          ' strSecureURL = strSecureURL & Request.ServerVariables("SERVER_NAME")
          strSecureURL = strSecureURL & Request.ServerVariables("URL")
          Response.Redirect strSecureURL
       End If
    %>
    
  5. Burnt Out

    Burnt Out Perch

    Pretty much what I was thinking. although now that I think about it, wouldn't it be better to use Transfer instead of redirect so that any submitted form data would also be carried over?

    Also, even if your not using ASP, I'm sure you can do something similar in PHP or whatever you are using. I assume your using a script language since you're using a https.
  6. irvo

    irvo Guppy

    Thanks guys. Yes, I'm using asp. I already use a scripted 404 error and was hoping to do something similar for the 403 error thrown up by the http request. I'll give your code a try.

Share This Page

JodoHost - 26,000 hosting end-users in 100 countries
Plesk Web Hosting
VPS Hosting
H-Sphere Web Hosting
Other Services