Apache: Forcing SSL and Authentication

Gary Thornock gthornock at yahoo.com
Tue Feb 13 16:44:45 MST 2007

--- Topher Fischer <javert42 at cs.byu.edu> wrote:
> I'm not using a vhost.  I'm just running the page at
> http://machine/dir/.  Can I make the necessary changes just
> within a block like this:
> <Directory /dir/>
> 	rewrite rules
> </Directory>
> I've played around with different settings, but nothing works
> yet.
> As far as I know, vhosts work with different host names, so I
> couldn't use a vhost configuration with this setup.  Is that
> correct?

Technically you probably are using at least one vhost, for the
https server.  I believe Apache always does it that way.  I've
got a setup at home where I wanted to do more or less the same
thing you're doing here, and I set it up like this:

# In the http vhost, or just somewhere in httpd.conf:
redirect permanent /mail https://hostname.example.com/mail

# In the https vhost (defined in ssl.conf):
<Directory /usr/local/www/mail>
  # appropriate stuff

I've also done it like this:
<Directory "/usr/local/mailman/archives">
  Options +FollowSymlinks
  <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{SERVER_PORT} !443
    RewriteRule . https://%{HTTP_HOST}%{REQUEST_URI}?%{QUERY_STRING}

Both methods seem to work.

More information about the PLUG mailing list