Forwarding http to https

Discussion in 'Mac OS X Server, Xserve, and Networking' started by CorporateFelon, Jun 15, 2010.

  1. macrumors regular

    CorporateFelon

    Joined:
    Oct 26, 2007
    Location:
    Boston, MA
    #1
    I haven't found anything in Server Admin yet, and have yet to read up on the documentation, but I cant seem to find a simple way to set up a site to automatically forward a user to https if they try to connect via http.

    My work around is to have a duplicate site set up on port 80 pointing at a directory only containing an .htaccess file that automatically redirects all requests to the https version. This simple solution works quite well, but I'd prefer a more controllable method.

    Any one know if what I am trying to accomplish is easily done in the Server Admin?
     
  2. Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    Using a .htaccess file is the way I always see used for this.
     
  3. macrumors 6502a

    CANEHDN

    Joined:
    Dec 12, 2005
    Location:
    Eagle Mountain, UT
    #3
    I personally always use PHP for this.
     
  4. macrumors 6502a

    Joined:
    Aug 11, 2008
    #4
    A simple way if your users are just hitting a landing page (e.g. they're typing 'www.example.com' into their browser and ending up at "http://www.example.com" where you want them to be at "https://www.example.com/very/secure" is to just have a default document that contains a simple meta redirect. Simple, dirty, not at all "robust" but sometimes its good enough, you know?
     
  5. macrumors 68000

    ulbador

    Joined:
    Feb 11, 2010
    #5
    Mod Rewrite


    RewriteRule ^/(.*) https://%{HTTP_HOST}/$1
     
  6. macrumors 6502a

    CANEHDN

    Joined:
    Dec 12, 2005
    Location:
    Eagle Mountain, UT
    #6
    The only downside to this is you would get an infinite loop if you're trying to redirect to the same page. http://www.mydomain.com/home/ to https://www.mydomain.com/home/ the page would continually redirect if using simple html. You'd need a scripting language PHP or something to check the domain to see if it needs to redirect.
     
  7. macrumors regular

    Joined:
    Jul 1, 2004
    #7
    You can do this entirely from within Server Admin.

    Set up 2 sites, one on port 80, and one on port 443 with SSL enabled.

    On the site on port 80, go to the Aliases tab and in the second pane, add a redirect as follows:
    type: redirect
    pattern: /
    path: https://www.yourdomain.com/
     

Share This Page