OS X ServerHOW TO: redirect http requests to https
If you have set up a site using ssl all requests for that domain not preceded by https it will point to the defualt web site. If what is required is that all requests for the domain on port 80 go to the 443 or in other words all requests for http go to https, there are a number of ways of doing this (using htaclearcase/" target="_blank" >cces or other scripting), however the following is the method we prefer.
1 go to the site config file at /etc/httpd/sites/
cd /etc/httpd/sites/
open the config file (e.g. 0016_195.75.175.184_443_secure.example.com.conf) in pico and edit the section
RewriteEngine On
RewriteCond % ^TRACE
RewriteRule .* - [F]
adding the following condition and rule and either delete or comment out the existing conditions and rules.
RewriteCond % !443
RewriteRule (.*) https://secure.example.com/ [R]
so that it reads as
RewriteEngine On
## RewriteCond % ^TRACE
## RewriteRule .* - [F]
RewriteCond % !443
RewriteRule (.*) https://secure.example.com/ [R]
2. In server admin duplicate the site secure.example.com, turn the web service off, edit the new site changing (from general) the port from 433 to 80, and from secure turn Enable Secure Sockets Layer off. You will now have two site config files in /etc/httpd/sites/ (e.g 0016_195.75.175.184_443_secure.example.com.conf and 0016_195.75.175.184_80_secure.example.com.conf).
3 Restart the web service and all requests to http://secure.example.com will be automatically redirected to https://secure.example.com.
It may appear contradictory to have two sites with the same name but one is on port 80 and the other is on port 443, Apache does allow this configuration. This method allows you to treat all virtual sites on an individual basis, you may wish some to be accessed only via ssl and others to be accesses via ssl and non ssl.
Last updated 08/06/05 Bruce Robbins
Platform: Mac OS X Server 10.3 or laterFurther readinghttp://httpd.apache.org/docs/mod/mod_rewrite.html
http://www.modssl.org/docs/2.8/ssl_howto.html
http://www.whoopis.com/howtos/apache-rewrite.html
http://joseph.randomnetworks.com/archives/2004/07/22/redirect-to-ssl-using-apaches-htaccess/
http://httpd.apache.org/docs-2.0/misc/rewriteguide.html
http://www.entropy.ch/software/macosx/docs/mod_ssl.html