PDA

View Full Version : Forwarding http to https




CorporateFelon
Jun 15, 2010, 11:12 PM
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?



angelwatt
Jun 16, 2010, 08:29 AM
Using a .htaccess file is the way I always see used for this.

CANEHDN
Jun 16, 2010, 08:43 PM
I personally always use PHP for this.

bartzilla
Jun 17, 2010, 08:24 AM
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?

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?

ulbador
Jun 17, 2010, 08:51 AM
Mod Rewrite


RewriteRule ^/(.*) https://%{HTTP_HOST}/$1

CANEHDN
Jun 18, 2010, 11:38 AM
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?

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.

ruud
Jun 18, 2010, 10:20 PM
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/