Redirecting access in Apache to https://

Ken Bradford ken at alpha2.com
Wed May 26 17:14:26 EDT 2004


> -----Original Message-----
> From: colug-bounces at colug.net [mailto:colug-bounces at colug.net]On Behalf
> Of Stephen J. Smith
> Sent: Wednesday, May 26, 2004 2:28 PM
> To: colug at colug.net
> Subject: Re: Redirecting access in Apache to https://
>
> 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
>

This also works very well too. (Using <Location> & Redirect inside of
<VirtualHost> was the other.) Now I've got a couple of options to play with.
Thanks.

BTW, doing it this way _did_ change the prefix to https: as one might
expect.

Ken Bradford
Alpha II Service, Inc.




More information about the colug mailing list