"Farooq Khan" writes:

> I have installed apache with mod_ssl.  Briefly, I want all http requests to a 
>particular
> VirtualHost to be redirected to https for the same VirtualHost.  Do I use 
>mod_rewrite to do
> this?
> 
>  
> 
> I have set up 4 VirtualHosts in the order:
> <VirtualHost a.com:80>
> <VirtualHost b.com:80>
> <VirtualHost c.com:80>
> <VirtualHost d.com:443>
> 
> All https://d.com requests work fine.  I want all http://d.com to be redirected to
> https://d.com but they are defaulting to http://a.com.
> 

The trouble is you haven't defined anything for requests on port 80 with
ServerName = "d.com" so apache just serves the first port 80 VH it finds
- in this case a.com.

The solution is to create a small VH for d.com:80 and fill it with just
a Redirect to the https site, e.g.

<VirtualHost d.com:80>
  ServerName d.com
  Redirect / https://d.com/
</VirtualHost>

This will bounce any request to d.com to the top of the https site. If
you want to be more specific so that http://d.com/foo/bar.html -->
https://d.com/foo/bar.html then use something like:

RedirectMatch (.*) https://d.com$1

Read the docs for these directives for more details. You can do a lot
with redirects and you only need to use rewrites if things get really
complicated.

Rgds,

Owen Boyle.
______________________________________________________________________
Apache Interface to OpenSSL (mod_ssl)                   www.modssl.org
User Support Mailing List                      [EMAIL PROTECTED]
Automated List Manager                            [EMAIL PROTECTED]

Reply via email to