Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7740048
  • 博文数量: 637
  • 博客积分: 10265
  • 博客等级: 上将
  • 技术积分: 6165
  • 用 户 组: 普通用户
  • 注册时间: 2004-12-12 22:00
文章分类

全部博文(637)

文章存档

2011年(1)

2010年(1)

2009年(3)

2008年(12)

2007年(44)

2006年(156)

2005年(419)

2004年(1)

分类: LINUX

2005-08-05 16:19:09

Tuesday, June 14 2005 @ 03:39 PM CDT
Contributed by:
Views: 1567 ArticlesA quick overview of doing redirects from non-ssl to ssl websites.

Ed. Note: While you should be able to do this in the 10.4 web GUI, you were unable do this in earlier versions of OS X Server. That's where this comes in handy, although this method should work for all version of OS X, or Apache on any system for that matter.


OS X Server HOW 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 htacces 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 %{REQUEST_METHOD} ^TRACE
RewriteRule .* - [F]

adding the following condition and rule and either delete or comment out the existing conditions and rules.

RewriteCond %{SERVER_PORT} !443
RewriteRule (.*) https://secure.example.com/ [R]

so that it reads as


RewriteEngine On
## RewriteCond %{REQUEST_METHOD} ^TRACE
## RewriteRule .* - [F]
RewriteCond %{SERVER_PORT} !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 later Further reading



阅读(2819) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~