Redirecting access in Apache to https://

Stephen J. Smith sjs at khadrin.com
Wed May 26 14:28:11 EDT 2004


On Wed, 2004-05-26 at 13:11, Ken Bradford wrote:
> But trying to redirect those connections to use ssl is failing. (I'm
> temporarily using a test location):

Hi.  I had a similar problem at some point.  Below is what I came up
with at the time [1]:

I had part of my site which I wanted to make sure I always accessed via
https. I imagine this is a fairly common occurrence. Rather than just
disallow connections on port 80, I wanted to redirect requests on port
80 to port 443. Unfortunately, the first thing I tried didn't work very
well:

[sjs at viper etc]$ cat httpd/conf.d/foo.conf
RedirectMatch /foo/(.*) https://khadrin.com/foo/$1

This lead to an infinite redirect. The solution I came up with was to
put the RedirectMatch directive inside a VirtualHost directive:

[sjs at viper etc]$ cat httpd/conf.d/foo.conf
<VirtualHost *:80>
    RedirectMatch /foo/(.*) https://khadrin.com/foo/$1
</VirtualHost>

Hopefully that might point you in the right direction.

[1] http://khadrin.com/kblog/archives/000037.html

-- 
Stephen J. Smith | sjs at khadrin.com | http://khadrin.com/



More information about the colug mailing list