The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

http to https

Discussion in 'General Discussion' started by stevejac, Jun 17, 2005.

  1. stevejac

    stevejac Member

    Joined:
    Dec 23, 2004
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    :eek: I just installed a SSL cert. on my server. with a subdomain, secure.c2chosting.net. Now when What I would like to ask is, how do I got about setting up the server so that everytime someone types in my domail it goes to the sercur domain name? would I redirect my domain to the sub domain then upload the website there?
    Thanks for your input
    SJ
     
  2. anup123

    anup123 Well-Known Member

    Joined:
    Mar 29, 2004
    Messages:
    897
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    This Planet
    See if the following in htaccess (or in httpd.conf) works:

    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{SERVER_PORT} !=443
    RewriteRule ^ https://yourdomain.tld%{REQUEST_URI} [NS,R,L]

    Perhaps someone could add how to do this redirction from domain.tld to sub.domain.tld
    Anup
     
  3. dan_c

    dan_c Active Member

    Joined:
    Jul 23, 2005
    Messages:
    39
    Likes Received:
    0
    Trophy Points:
    6
    here is a script I came across written in JAVASCRIPT. It will automatically make the site encrypted (https), even if the user specifically types in http://

    <SCRIPT LANGUAGE="JavaScript">
    if (location.protocol != 'https:'){
    window.location= 'https://' + location.host + location.pathname + location.search
    }
    </SCRIPT>
     
  4. anup123

    anup123 Well-Known Member

    Joined:
    Mar 29, 2004
    Messages:
    897
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    This Planet
    Problem with java script is that it would break if users disable java script in browser for some reason or the other.

    Anup
     
  5. dan_c

    dan_c Active Member

    Joined:
    Jul 23, 2005
    Messages:
    39
    Likes Received:
    0
    Trophy Points:
    6
    true. perhaps it could be written in PHP or some other server-side scripture.
     
  6. truehustercom

    truehustercom Member

    Joined:
    Aug 27, 2004
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Here is a way to do it by php. You might want to use $_SERVER["REQUEST_URI"]
    if you want the user to be redirected to the secure page they where trying to find.

    PHP:
    <?

     if (
    $_SERVER["SERVER_PORT"] != '443')
        {
           
    //$redirect = "https://secure.c2chosting.net/".$_SERVER['REQUEST_URI'];     
           
    $redirect "https://secure.c2chosting.net";
          
         
    header ("Location: $redirect");
        }
    ?>
     
  7. dan_c

    dan_c Active Member

    Joined:
    Jul 23, 2005
    Messages:
    39
    Likes Received:
    0
    Trophy Points:
    6
    wow that is excellent.

    One minor edit is when using REQUEST_URI instead of
    $redirect = "https://www.yourdomain.com/".$_SERVER['REQUEST_URI'];
    use:
    $redirect = "https://www.yourdomain.com".$_SERVER['REQUEST_URI'];

    note that I removed the "/" at the end of your domain address, otherwise your redirected url will return as somethin like https://www.yourdomain.com//yourpage.php
     
    #7 dan_c, Jul 25, 2005
    Last edited: Jul 25, 2005
  8. wa4fat

    wa4fat Well-Known Member

    Joined:
    Dec 30, 2001
    Messages:
    51
    Likes Received:
    1
    Trophy Points:
    8
    Another redirection method

    You may wish to consider using a simple .htaccess redirect statement.

    In the root of your website, you'd place the following withing an .htaccess file:

    redirect /index.html https://yourdomainname.com

    This would globally redirect folks entering your index.html page (substitute your flavor .htm etc., if different) to the secure https:// version of your site.

    All the best -- Bill
     
  9. skaboobie

    skaboobie Member

    Joined:
    Mar 12, 2004
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Buffalo, NY, USA
    I can't get https working with my domain ... at all!

    Hi. I'm a cPanel newbie, and to some extent, an Apache newbie as well. I am the site administrator for cPanel. That is, I have access to WHM.

    Through WHM, I created a site (virtual host). I can log in as the admin for the virtual host via https.
    That is, I go to https://example.com:2083. (No, the FQDN is not example.com. I'm not that much of a newbie.) Everything works fine there. I succesfully set up a site at the virtual host, and I can view it via http just fine. However, I would also like to go to the same site with https. The problem is that when I go to https://example.com via Mozilla/Firefox, I get the error, "The connection to example.com has terminated unexpectedly. Some data may have been transferred.". If I use MSIE, I get a "Cannot find server" error.

    Via cPanel, I went into the "SSL Manager" and I generated an SSL key and an SSL certificate. Is there something else I'm missing?

    My guess is that it is the firewall, since I need to listen on port 443. Does cPanel have a tool to configure the firewall, or is it safe to just edit the iptables rules like I would on a Linux workstation? (BTW, I'm running Red Hat Enterprise 3 on the server.)

    Is there some apache configuration I would need as well? :confused:
     
Loading...

Share This Page