Results 1 to 9 of 9

Thread: http to https

  1. #1
    Member
    Join Date
    Dec 2004
    Posts
    12

    Red face http to https

    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. #2
    Member
    Join Date
    Mar 2004
    Location
    This Planet
    Posts
    984

    Default

    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. #3
    Member
    Join Date
    Jul 2005
    Posts
    39

    Default

    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. #4
    Member
    Join Date
    Mar 2004
    Location
    This Planet
    Posts
    984

    Default

    Problem with java script is that it would break if users disable java script in browser for some reason or the other.

    Anup

  5. #5
    Member
    Join Date
    Jul 2005
    Posts
    39

    Default

    true. perhaps it could be written in PHP or some other server-side scripture.

  6. #6
    Member
    Join Date
    Aug 2004
    Posts
    8

    Default

    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 Code:
    <?

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

  7. #7
    Member
    Join Date
    Jul 2005
    Posts
    39

    Default

    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
    Last edited by dan_c; 07-25-2005 at 09:30 PM.

  8. #8
    Member
    Join Date
    Dec 2001
    Posts
    51

    Default 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. #9
    Member
    Join Date
    Mar 2004
    Location
    Buffalo, NY, USA
    Posts
    9

    Question 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?

Similar Threads

  1. Http to Https Redirection
    By lloyd_tennison in forum cPanel & WHM Discussions
    Replies: 3
    Last Post: 07-07-2007, 06:49 AM
  2. routing from http to https
    By ThadBry in forum cPanel & WHM Discussions
    Replies: 1
    Last Post: 12-21-2005, 11:17 AM
  3. https work, http does not
    By jimmshepard in forum cPanel & WHM Discussions
    Replies: 1
    Last Post: 02-22-2005, 10:09 AM
  4. Redirect Http to Https
    By billau in forum cPanel & WHM Discussions
    Replies: 16
    Last Post: 10-26-2004, 09:12 PM
  5. https vs. http
    By SupermanInNY in forum cPanel & WHM Discussions
    Replies: 5
    Last Post: 12-14-2003, 09:29 PM